Not sure if i’m taking the right approach here. I’ve set up various controller actions for variations on a query and for each i’ve created an associated view/template. All use copies of the same template so it seems counter productive to have individual views……if I decide to change the layout i’d have to change each template.
Here’s the actions:
def schedule #routes to /products/schedule.html.erb
@products = Product.where('release_date >= ?', Date.today)
end
def active_lines #routes to /products/active_lines.html.erb
@products = Product.where('release_date <= ?', Date.today)
end
I’d prefer to have a general products template for these and further actions.
If you have several actions displaying list of products, and all have the same “look and feel”, you should use a single template. Use render to specify the template:
Create a single template
products/list.html.erbinstead of the 2 previous templates.