开发者

Rails 3 : CacheHelper, cached block doesn't render in the production environment

开发者 https://www.devze.com 2023-03-16 12:22 出处:网络
I hope that someone may help me because I\'m facing such a strange behavior concerning Rails 3. Here\'s the problem :

I hope that someone may help me because I'm facing such a strange behavior concerning Rails 3.

Here's the problem :

I've developed a blog in which each article may have one or more tags. I used a classic method to assign tags to each article, using a third model: taggings which makes the bridge between an Article and its tags usign their respective ids.

Then, in the index page of my articles, I have a sidebar showing all the tags.

So far everything works well in the Development environment: all the tags show up. But... When I launch the site in a production environment, no tags appear at all but they do are saved in the production database.

Here's the code I use within my view to show up the tags:

<ul id="tags">
<% cache("all_tags") do %>
    <% for tag in Tag.find(:all, :order => "name") %>
        <li><%= link_to "#{tag.name}", tag_path(tag) %></li>
    <% end %>
<% end %>
</ul>

Also I've tried to just put something like

<%= Tag.all %>

开发者_运维知识库And it seems to produce a strange result for each tag saved in the database:

#<Tag:some_alpha_numeric_caracters>

Does anyone have an idea about this strange behavior?

Thanks a lot for all your help you may bring to me :)

Regards, M. Millet


Ok so I finally found the problem. I had to simply delete:

<% cache("all_tags") do %>

It seems that what the cache contains (usign the cache function) is not rendered in production. But I don't know why.. So even if I've resolved my problem it would be great if anyone can explain me why the cache block doesn't render in a production environment.

Thanks :)

Best regards, Kulgar.

0

精彩评论

暂无评论...
验证码 换一张
取 消