Caching/session Question

I have a site which basically has a layout page displaying the 3 latest news items down the left hand side of the page and the main content in the center. The layout renders a partial to display the 3 latest news items

_latestnews.rhtml <% for article in @latestarticles %> <a href=""><%= article.title %> </a><small>(<%= article.created_at.to_s(:long) %>)</small> <br/> <% end %> <%= link_to 'Read more recent news items', :action => 'news'%>&#187

layout.rhtml The layout also contains a reference to the main content <%= @content_for_layout %>.

controller def home @latestarticles = Article.get_latest_news() end

When i click on the about_us page i get an error because the new page doesnt have access to the 3 latest news items so for the about us page to get it to work i have to the following

def about_us @latestarticles = Article.get_latest_news() end

and for the contact page def contact @latestarticles = Article.get_latest_news() end

So for every page in the site i want the 3 latest news items displayed down the left hand side but i dont want to have to include @latestarticles = Article.get_latest_news() in every method when i show a new page.

Whats the best way to manage this as im not really experienced with caching, sessions and stuff like that.

Appreciate any advice?

In your app/controllers/application.rb file add the following: