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.

https://github.com/rails/rails/blob/b2eb1d1c55a59fee1e6c4cba7030d8ceb524267c/activerecord/lib/active_record/integration.rb

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.