Hi

When creating a view to display infromation obtained from a model,
should the view always get this information from the controller, or
should it get it directly from the model?

For example, say I have Class and Student models, and they are in a
many to many relationship via the enrolled table. Now my view wants to
display the students of a given class. Should the controller run the
query and store it in a variable (say @students) that is passed to the
view? Or, should the view just access it directly like

<% for enrolled in @class.enrolled_students %>
<%= enrolled.student.name %>

I like the second way because it does not require me to put any code
in the controller. I just feel like this is coupling the view and to
the model and I can't tell if that is a bad thing in an MVC framework?
I feel like it is.

Thanks in advance

--~--~---------~--~----~------------~-------~--~----~
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 [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to