我想我一定是遗漏了一些关于集合缓存- 1.3.1如何工作的东西。当我将cached: true属性添加到呈现时,当模型更改时,不会刷新缓存。但是,如果没有这个属性,它将如预期的那样工作。
attending.html.erb
<%= render partial: 'attending_item', collection: @attendees, locals: {reserved: true}, cached: true %>_item_attending.html.erb
<% cache([attendee.user, attendee, reserved]) do %>
<li class="attendee_id_<%= attendee.id %> <%= reserved ? 'reserved' : 'confirmed' %>">
<%= image_tag(attendee.user.profile.avatar_url(:avatar), size: '25x25') %>
<%= attendee.user.full_name %>
</li>
<% end %>用户模型将通过配置文件模型上的touch: true进行更新,例如,当他们在那里更新时:
belongs_to :user, touch: true有人能向我解释我缺少什么或者不了解集合缓存是如何工作的吗?也许是Rails中的一个bug
发布于 2017-01-27 00:03:53
游戏后期,但我不认为您的缓存是到期的,因为它依赖于用户和保留的值。
看看multi_fetch_fragments 创业板的更好的文档,它被合并到Rails中,从而增加了一些线索。
我认为您希望将您的cache: true更改为cache: Proc.new { |attendee| [attendee, user, reserved] },以考虑到那里的更改。
此外,我相信您希望在自动缓存部分时删除_item_attending.html.erb文件中的_item_attending.html.erb块。
https://stackoverflow.com/questions/36934496
复制相似问题