Ruby Forum Ruby on Rails > Globalize, partial, cache

Posted by Igor K. (demoversion)
on 28.09.2007 17:05
Hello,

I have a problem or don't have :)
Please check following if i did right:

I have a web pages, that includes partials. Also i used Globalize plugin
for translating web-pages. I get a problem with caching partials when
used next code:

<% cache "header" do %>
    <%= render :partial => '/header' %>
<% end %>
But after this header cached with one language,and changing language no
make changing header.

So i try this code(method get_cuurent_lang returns string with current
lang or default):

<% cache "header-#{get_current_lang}" do %>
    <%= render :partial => '/header' %>
<% end %>
And i got header-us-US, header-ru-RU cached pages.

Thanks
Posted by Valery Visnakov (balepc)
on 11.03.2008 19:35
Well, if this working fine, then you did everything fine. You need to 
specify language to caching mechanism. The best way to understand 
fragment caching, is to investigate '/tmp/cache' folder.