[Rails] Rails 101 - Validation
Stefan Arentz
stefan.arentz at norad.org
Fri Dec 10 22:04:50 GMT 2004
On Dec 10, 2004, at 10:47 PM, Jarkko Laine wrote:
> Stefan,
>
> On 10.12.2004, at 23:41, Stefan Arentz wrote:
>
>>
>> On Dec 10, 2004, at 11:54 AM, David Heinemeier Hansson wrote:
>>> Beware, that if you set the default column value to 0, then it'll
>>> initialize the field with a 0.
>>>
>>> (I really should get Rails 0.9, shouldn't I :)?)
>>>
>>> ...also, render_action "add" just renders the template. It doesn't
>>> call CountriesController#add.
>>
>> I upgraded to the beta-gems but it still behaves the same. I feel
>> pretty stupid not getting such a simple web app concept to work :)
>>
>> Does anyone have a working example of this?
>
> Are you sure that the default value of your column is not 0 (see
> David's comment above)? CocoaMySQL has an annoying habit to declare
> "default 0" to integer type columns even if you don't specify it
> yourself. I've got caught by this myself a few times.
I could live with the default value. The problem is that when I submit
the form with the integer field set to '1234a' that it resets back to
0. Because the validation kicked in and rejected the value. I would
rather keep the original value and show an appropriate error.
I'm looking at the rails code but it is a bit difficult to see where
the value gets lost.
S.
More information about the Rails
mailing list