Jim Burgess wrote:
>
>> you can even shorten that to
>>
>> validates_numericality_of :children, :if => Proc.new { |applicant|
>> applicant.children !="" }
>>
>
Looks like a case for allow_nil:
validates_numericality_of :children, :allow_nil => true
The documentation at
http://ar.rubyonrails.org/classes/ActiveRecord/Validations/ClassMethods.html#M000091
mentions
:allow_nil - Skip validation if attribute is nil (default is false).
Notice that for fixnum and float columns empty strings are converted to
nil.
Stephan
> Cool!
> Thanks a lot.
--
Posted via http://www.ruby-forum.com/.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Ruby
on Rails: Talk" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---