Does rails have a validator like validates_numericality_of
for boolean or do I need to roll my own?
views:
33answers:
1
+2
A:
I believe for a boolean field you will need to do something like:
validates_inclusion_of :field_name, :in => [true, false]
From an older version of the API: "This is due to the way Object#blank? handles boolean values. false.blank? # => true"
I'm not sure if this will still be fine for Rails 3 though, hope that helped!
Sonia
2010-08-31 10:50:36
lol @ Rails 3. I can bet this will be the caveat for months to come. Ok, I thought this migth have been it and you agree. Thanks!
DJTripleThreat
2010-08-31 11:19:39