Re: [Rails] validates_numercality_of with allow_nil.
On 19 June 2011 13:38, Michael Pavling <pavling@gmail.com> wrote:
> On 19 June 2011 12:23, Mauro <mrsanna1@gmail.com> wrote:
>> In the model I have:
>>
>> validates :square_meters_public_land, :barrier_meters, :numericality
>> => { :greater_than_or_equal_to => 0 }, :allow_nil => true
>>
>
> Depending on your Rails version.... try:
>
> validates :square_meters_public_land, :barrier_meters, :numericality
> => { :greater_than_or_equal_to => 0 }, :if => Proc.new {|o|
> !o.square_meters_public_land.blank?}
>
> or
>
> validates :square_meters_public_land, :barrier_meters, :numericality
> => { :greater_than_or_equal_to => 0 }, :if =>
> :square_meters_public_land
Same problem, I don't know how to insert nil values for the two fields.
--
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 rubyonrails-talk@googlegroups.com.
To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
0 Comments:
Post a Comment
Subscribe to Post Comments [Atom]
<< Home