[Rails] Re: How To Validate Boolean Form Field
Nithin Reddy
jashugan at gmail.com
Wed Mar 1 19:40:33 GMT 2006
To be able to validate a field, it must be present.
Try...
validates_presence_of :first_name, :last_name, :street, :city,
:state, :zip, :AZ_resident
- Nithin
On 3/1/06, Matthew Feadler <matthew at feadler.com> wrote:
> > 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/.
> _______________________________________________
> Rails mailing list
> Rails at lists.rubyonrails.org
> http://lists.rubyonrails.org/mailman/listinfo/rails
>
More information about the Rails
mailing list