On 19 June 2011 21:26, Bill Felton <[email protected]> wrote:
>
> On Jun 19, 2011, at 2:43 PM, Mauro wrote:
>
>> On 19 June 2011 13:43, Bill Felton <[email protected]> wrote:
>>>
>>> On Jun 19, 2011, at 7:23 AM, Mauro wrote:
>>>
>>>> In the model I have:
>>>>
>>>> validates :square_meters_public_land, :barrier_meters, :numericality
>>>> => { :greater_than_or_equal_to => 0 }, :allow_nil => true
>>>>
>>>> but if, in the field, on create, I don't insert a value I have the
>>>> error "field is not a number".
>>>
>>>
>>> Include the :allow_blank option if the fields are not required.
>>> I generally think about this in terms of "specifying a validation always 
>>> includes :required; if that's not what I want, I have to include 
>>> :allow_blank".
>>
>> That's ok, they are numeric fields I thought that allow_nil should be ok.
>
> I would have expected :allow_nil to work, but apparently it's giving 
> problems?  FWIW, I always tend to think in terms of :allow_blank rather than 
> :allow_nil.  Perhaps an artifact of my years in Smalltalk?
> If :allow_nil isn't working, as I gather from the posts that appeared before 
> mine (after I posted, but long before mine showed up), have you tried 
> :allow_blank?  Does that work better, worse, or no different?

allow_blank works.

-- 
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.

Reply via email to