I am trying to validate the presence of the attribute with a condition to be true, i.e. the attribute should be provided by user mandatorily if the user is not an admin.
validates :attribute_name, presence: { :if => :user.is_admin? }
undefined method `is_admin?' for :user:Symbol Did you mean? is_haml?
I have also tried user.is_admin()==True, It also throws error: undefined method `is_admin' for :user:Symbol Did you mean? is_a?
I have this attribute in the users table: t.boolean "is_admin", default: false
Aucun commentaire:
Enregistrer un commentaire