I have something like this:
class Suite < ActiveRecord::Base
has_many :tests
end
class Test < ActiveRecord::Base
belongs_to :suite
end
And I'm using the cache_digests gem to do fragment caching.
I want that when I update a Suite object, the children tests caches expire.
I tried to put a touch: true
in the has_many
association without success.
How can I do that?
Thanks in advance
EDIT
I was doing my cache like this:
<% cache test do %>
<tr>
etc...
<% cache test.suite do %>
etc..
<% end %>
</tr>
<% end %>
But it doesn't work, because when I edit a suite, their tests isn't touched. So, I changed my cache declaration to something like this:
<% cache [test, test.suite] do %>
etc..
<% end %>
And it worked just as expected.
When I edit a test, or a suite, one of those is touched, so, the fragment got expired and I got the new version just as expected.
Thanks to @taryn-east for the help.