Re: [Rails] validates_numercality_of with allow_nil.
On 19 June 2011 13:18, Mauro <mrsanna1@gmail.com> wrote:
> I'm using rails 3.0.9, sorry but I don't undestand why I have to use
> the if clause.
> allow_nil => doens't work with validation_numericality_of?
I didn't say you "had to", I suggested you try it... did you? Did it work?...
I doubt it anyway, as I had copied your code without checking it, and
just added the "if" I'd copied from one of my models. I notice now
that you're not using "validates_numericality_of", you're using
"validates" and seem to be trying to check two values - can't say
that's an idiom I'm familiar with, but it may be valid (although I
can't see it in the docs:
http://ar.rubyonrails.org/classes/ActiveRecord/Validations/ClassMethods.html#M000091)
What about:
validates_numericality_of :square_meters_public_land,
:greater_than_or_equal_to => 0, :allow_nil => true
validates_numericality_of :barrier_meters, :greater_than_or_equal_to
=> 0, :allow_nil => true
--
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