Rails 5 - Collection caching not refreshing
<p>I think I must be missing something here on how <strong><a href="http://edgeguides.rubyonrails.org/caching_with_rails.html#fragment-caching" rel="nofollow">Collection caching - 1.3.1</a></strong> works. When I add the <code>cached: true</code> attribute to the render it <strong>will not</strong> refresh the cache when a model changes. However, without this attribute it will work as expected.</p>

<p>attending.html.erb</p>

<pre><code>&lt;%= render partial: 'attending_item', collection: @attendees, locals: {reserved: true}, cached: true %&gt;
</code></pre>

<p>_item_attending.html.erb</p>

<pre><code>&lt;% cache([attendee.user, attendee, reserved]) do %&gt;
  &lt;li class="attendee_id_&lt;%= attendee.id %&gt; &lt;%= reserved ? 'reserved' : 'confirmed' %&gt;"&gt;
  &lt;%= image_tag(attendee.user.profile.avatar_url(:avatar), size: '25x25') %&gt;
  &lt;%= attendee.user.full_name %&gt;
 &lt;/li&gt;
&lt;% end %&gt;
</code></pre>

<p>The <strong>user</strong> model will get updated via a <code>touch: true</code> on the Profile model, so when they update there avatar for example:</p>

<pre><code>belongs_to :user, touch: true
</code></pre>

<p>Can someone explain to me what I am missing or not understanding how a <strong>Collection cache</strong> works, maybe it's a bug in <strong>Rails</strong>?</p>