Ruby on Rails Monday, August 30, 2010

On 30 August 2010 18:01, Ithelp Eighty-five <lists@ruby-forum.com> wrote:
> Hello everyone I have a problem in my app with the validation on
> numericality. The field should be all numbers, and if an user types for
> example "12345abc" into the field an error is raised and the data is not
> saved. But in the field where the error was raised it now says "12345",
> I want this field to be blank instead.

In the update and/or create action, after the failed save, just blank
the field in the object being passed to the view. So if the object is
@my_thing and the field is value then set @my_thing.value = "" or
possibly nil might be better.

Colin

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

No comments:

Post a Comment