No Pugs

they're evil

validates_presence_of with a boolean set to false doesn't work...

Posted by miles 12/04/2011 at 09h32

It looks like if a boolean property is set to false and it has a validates_presence_of validation on it, that the validation will fail. At least in rails 2.3.8 and rails 2.3.5 and I’m assuming all older and possibly newer versions.

It probably has to do with this:

  false.blank?

evaluating as true.

What worked for me was to use validates_inclusion_of instead:

  validates_inclusion_of :is_present_in_sentence, :in => [true, false]

Posted in | no comments |

Trackbacks<

Use the following link to trackback from your own site:
http://nopugs.com/trackbacks?article_id=34

Leave a comment

Leave a comment