views:

18

answers:

1

Hi, Currently I am using fragment caching with an object key. And I expire the cache using Touch with updates the updated_at column and then the current cache become obsolete. And a new cache is generated the next time.

<% cache do product %>

The cache key for an object looks like this

table_name/ID-updated_at

Now I want to cache my products somewhere else. To do so I would like to do same thing as before which is simply give the object in cache options, but I can't do that :(

It would be great if I could generate a key like this in order to still have my cache expired with the Touch.

table_name/ID-something_updated_at
<% cache product,something do %>

Unfortunately this is not possible, does someone has any idea how I could solve my problem?

Greg

A: 

You can pass any old array you like to the fragment, so it's a pretty simple change to achieve what you're after:

<% cache [product, other, product.updated_at] do %>
  ...
<% end %>
NZKoz