I have a simple rails app that uses a master layout for all pages. I would like to have a footer in this layout that displays data from the model, so that you can see the data no matter what page you are on.
Currently I have only a single controller, with a few very simple views that are rendered into the layout with no action methods defined in the controller. The layout has something like:
<div id="footer"><%= controller.get_data %></div>
Where get_data
, of course, just pulls the data from the model. This seems like a poor way to do this because I can't add more controllers without breaking the layout.
My question is: what is the best way to retrieve data from the model to be displayed in the main layout when the request could be handled by any controller rendering any view into that layout? Where should get_data be defined, or what would be a cleaner way to handle this?