Rails 4 ActiveRecord Exclusion Validation for Association -


i'm trying validate association in model , exclude object validation, can't seem work. here's code:

validates :user, presence: true, exclusion: { in: [:lot_high_bidder] } 

i imagine it's trying direct comparison of :user symbol :lot_high_bidder fail, mean can't use method name in exclusion validator or syntax wrong?

rails has validates_associated method used validate association on models

http://apidock.com/rails/activerecord/validations/classmethods/validates_associated

not sure if can validate user_id instead of user association.

hope helps


Comments

Popular posts from this blog

wordpress - (T_ENDFOREACH) php error -

Export Excel workseet into txt file using vba - (text and numbers with formulas) -

Using django-mptt to get only the categories that have items -