[Rails] Re: How To Validate Boolean Form Field
Matthew Feadler
matthew at feadler.com
Wed Mar 1 09:57:08 GMT 2006
> Have you tried this?
>
> def validate
> errors.add(:AZ_resident, "You must be an Arizona resident") if
> AZ_resident = false
> end
After correcting syntax errors, I tried:
def validate
errors.add(:AZ_resident, "You must be an Arizona resident") if
:AZ_resident == false
end
No difference. Forms with AZ_resident left FALSE are happily inserted
into the database; no errors raised.
But, moreover, what is wrong with my use of the validates_acceptance_of
method? According to the docs found @
http://rubyonrails.org/api/classes/ActiveRecord/Validations/ClassMethods.html,
I'm doing everything right.
Thanks folks,
-ELf
--
Posted via http://www.ruby-forum.com/.
More information about the Rails
mailing list