0

这是我的代码:

<% cache(author_helper_method) do %>
  <div class="author">
    <% @authors.each do |author| %>
      <% cache(author) do %>
        <h2>My name is <%= author.name %></h2>
        <% author.articles.each do |art| %>
          <p>I wrote: <span style="text-decoration: underline"><%= link_to art.name, articles_show_path(art) %> </span></p>
        <% end %>
      <% end %>
    <% end %>
  </div>
<% end %>

问题是我的文章和文章链接除了第一个之外没有呈现。只有名称正在呈现。这是我的页面的样子:

这是一个糟糕的作者索引页面。有史以来最糟糕的情况之一。

统计 我的名字是 Yasmeen Conn

我写道:一些评论者

我的名字是凯伦马克斯

我的名字是海蒂·杜尔根博士

我的名字是 Reta Glover Sr。

我的名字是基利·克洛克

我的名字是米歇尔·雷格

我的名字是 Josue Parisian

当我从俄罗斯娃娃缓存中读取时,只出现名称,并且只出现第一篇文章“一些评论者”。知道为什么吗?

仅供参考,作者有很多文章,一篇文章属于作者。如果需要,这里是一些其他代码:

module ApplicationHelper
  def author_helper_method
    count = Author.count
    max_updated_at = Author.maximum(:updated_at).try(:utc).try(:to_s, :number)
    "authors/all-#{count}-#{max_updated_at}"
  end
end
4

0 回答 0