Hi Rails I can't seem to use a boolean value 'false' with validates_presence_of. It always fails. I even tried using 'f'. What's the proper way to set a false value? Isn't false a "present" value in a boolean column? What I want is to require either true or false, but prevent nil :) Thank you -- Hendy Irawan www.hendyirawan.com
on 2007-07-28 08:42
on 2007-07-28 17:20
Hendy Irawan wrote: > > > What I want is to require either true or false, but prevent nil :) > > From the API docs for validates_presence_of: "If you want to validate the presence of a boolean field (where the real values are true and false), you will want to use validates_inclusion_of :field_name, :in => [true, false] This is due to the way Object#blank? handles boolean values. false.blank? # => true" This should do the trick! --- Ryan Carmelo Briones -- View this message in context: http://www.nabble.com/ActiveRecord-validates_prese... Sent from the RubyOnRails Users mailing list archive at Nabble.com.