Wednesday, August 1, 2012

[Rails] Globally keyed cache fragments across all controllers

In the documentation for fragment caching
(http://guides.rubyonrails.org/caching_with_rails.html#fragment-caching),
this is stated:

If you don't want the cache block to bind to the action that called
it, You can also use globally keyed fragments by calling the cache
method with a key, like so:

<% cache('all_available_products') do %>
All available products:
<% end %>

This fragment is then available to all actions in the
ProductsController [...]

Is it possible to add a globally keyed cache fragment that is available
in _all_ controllers, not just ProductsController as in the example
above? I plan on having a list of the top 10 items of one of my models,
in my layout, so it'd be ideal to have that cached globally.

--
Posted via http://www.ruby-forum.com/.

--
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-talk@googlegroups.com.
To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

0 Comments:

Post a Comment

Subscribe to Post Comments [Atom]

<< Home


Real Estate