Set custom cache_key of Fragment Caching

I want to cache with custom cache_key of Fragment Caching because I don’t want to change updated_at.

So, I googled and found monkeypatch(https://gist.github.com/tispratik/9276110). But It just a monkey patch.

Is there a way to set custom cache_key?

Thanks

In Rails 5, you can turn cache versioning on and override #cache_version in your model if you’d like to return a different column.

In earlier versions of Rails, you can pass different column names to #cache_key, e.g., model.cache_key(:last_modified).

In either case, you can probably just override #cache_key in the model.