Ruby on Rails Wednesday, September 1, 2010

pepe wrote:
>> Another question... if I want to set a field blank for each field that
>> had an error how would i do that?
>
> I would do this in the model, after validations. I would use 'each' or
> 'valid?', depending on how you want to handle it.
>
> If you clear the field in the model, after validations have run (and
> you have your errors for display in the view), then your fields will
> be already set for your view. I think that clearing the fields in the
> controller or the view is a mistake as it's not their job to manage
> the contents of the model values. I would only do this in the
> controller if the default behavior is not to have the values cleared;
> for example, if the values should be cleared in one part of your
> application and not in another part of your application.

Can you go into more detail on how to do this? I'm new to Ruby on Rails.

Thanks
--
Posted via http://www.ruby-forum.com/.

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