Forum: Ruby on Rails Cache and content_for

Announcement (2017-05-07): is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see and for other Rails- und Ruby-related community platforms.
Ff8cc764b86f8b9c6a87764f45cb96c8?d=identicon&s=25 matiyam (Guest)
on 2007-07-19 11:39
(Received via mailing list)

I want to cache some fragment to place in a sidebar of my default
and i want to use content_for to place it.

It the API it says:

NOTE: Beware that content_for is ignored in caches. So you
     shouldn't use it for elements that are going to be fragment cached.

I am not really sure what means, because i have tried placing a cache
inside a content_for block and it looks that it works.

I want to know if i am using it correctly and wether it will be a
problem in
the future because that's not supposed to work.

In my general layout i have:

/app/views/layout/general.html.erb :

   <div id="divsidebar">
                          <%= yield :sidebar %>

In mi view, i have:

/app/views/controller/index.html.erb :

<% content_for :sidebar do %>
<% cache(:action_suffix => "tagcloudcache") do %>
  <%= render(:partial => "tagcloud") %>

<% end %>
<% end %>

My question is:
Is that not supposed to work? Because it works. Is there a better way of
doing it?

Thanks a lot for your attention!!

-- M
This topic is locked and can not be replied to.