I am building a rails app that has a number of models, one of which is Items.
Items contains a short list of products and supporting information.
I need to display this information on every page in the app.
In my views I've added
<%= render @items %>
and then added the partial 'items/_item.html.erb'
Now, to get this all to work, I also need to define the variable
@items = Item.all
My question is, what is the correct way to define this variable? I could add this line to every view for every controller, but that doesn't seem very DRY.
Should I be defining this in the application controller? If so, will this cause any issues if I also want to maintain access to the Items index page?
Sorry if this is a simple question. I'm trying to think through the best approach, and haven't found much written about this case. Grateful for fresh ideas and perspective!
Thank you!