Brian wrote:

> I'm new to both rails and MVC, so please correct me if I
> misunderstand.  But it seems that controllers DO handle user input for
> the typical web application.  A view helps a user format that input,
> but it can't receive anything.  In fact, I could just send an http
> request to a rails application before ever interacting with UI.  The
> controller is what processes this request, consulting models if
> necessary.  The view isn't involved until the application tries to
> send information back to me.

Regardless of the direction data travels, a controller should dispatch to the 
view or model as soon as possible. For example...

   Model.create! params[:model]

That common idiom passes <form> parameters directly into the createe, in the 
model. This might look like a violation of the rule "no view data leaking into 
the model", where the params[] are indeed CGI Query details wrapped up in a 
convenient package, but note that params[:model] should only contain data 
primitives - strings and strung integers.

In real life coding, actions can get thick. They might need to use lots of if 
statements to triage input, for example. The rule "all biz logic in the model" 
is not a rule, it is a goal. The closer you get to it, and the more often you 
refactor a design towards that goal, the better.

-- 
   Phlip


--~--~---------~--~----~------------~-------~--~----~
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+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to