Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Rails: validates_length_of :allow_nil does not allow nil

Using: Rails 3.0.3.

I am using this code in the validator:

validates_length_of :birth_date_8, :minimum => 8, :allow_nil => true, :message => "value_is_not_a_proper_date", :if =>:family_birthday? 

It does not, however, allow the field to be nil. I have checked so it is not a matter of the :if => :family_birthday? that is messing things up.

Is there something wrong with the code?

like image 649
Christoffer Avatar asked Oct 04 '11 19:10

Christoffer


1 Answers

Try allow_blank instead of allow_nil :-)

like image 56
chrispanda Avatar answered Sep 19 '22 18:09

chrispanda