To make a long question short: I'm fairly new to caching in Rails.
What's the best way to cache stuff that is used in the layout without
caching the entire action/view?

Lets say I have the following in my Application controller to set some
variables that are used in my layout:

  before_filter :get_sidebar_items

  def get_sidebar_items
    @menu_items = MenuItem.all
    @archives = Post.all_grouped_by_month
  end

I can easily cache the display of the menu items in
application.html.erb using a fragment:

<% cache(:menu_items) do %>
  <% for i in @menu_items %>
    <%= i.name %>
  <% end %>
<% end %>

Problem is, that doesn't cache the database query. Is there a nifty
way to cache some global stuff like this? As far as I can tell, the
Caching Guide doesn't touch on this much.

-- 
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Talk" group.
To post to this group, send email to rubyonrails-t...@googlegroups.com.
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en.

Reply via email to