Ruby on Rails Tuesday, November 30, 2010

Please quote when replying.

Kai Schlamp wrote in post #965115:
> Thanks for the answers.
>
> One last general question. Where do you validate your parameters
> fetched by "params" that should be passed to models? Do you check them
> right away in the controller and give them cleaned up to the model, or
> do you just provide them as they are (maybe just put them in single
> variables) and let the model check them?

It's usually the model's job to validate. That's what the validates_*
methods are for.

Validation in the controller will lead to repetitive code scattered all
over the application.

Best,
--
Marnen Laibow-Koser
http://www.marnen.org
marnen@marnen.org

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