I have a RESTful controller that is responsible for building many different models. This means that any given view would requires a handful of variables to be set before it can be rendered correctly. If I set those variables in the controller, then the code would have to be duplicated across different actions that might render that view. For example, rendering Page 1 requires 5 variables. If show, create, and update all render that view, then the code to set those 5 variables is duplicated across those controller actions. The alternative is to just put all of that code inside the view. But that can get really ugly:
<% variable1 = Model1.where(some conditions) %>
<% variable2 = Model2.where(some other conditions) %>
<% variable3 = Model3.where(some third conditions) %>
I'm hesitant about this solution because of how much code goes into the views. I've always followed the principle that the code in views shouldn't touch the database. Another method I'm entertaining is creating private methods that focus on setting variables and rendering a view. This method could be called by all the actions that require rendering.