Provides a rails cache key for caching data that should be invalidated whenever any ActiveRecord instance of a specific type is created, updated, or destroyed.
Add this line to your application's Gemfile:
gem 'blanket_cachekey'
And then execute:
$ bundle
Or install it yourself as:
$ gem install blanket_cachekey
Include BlanketCachekey within your ActiveRecord class:
class Bar < ActiveRecord::Base
include BlanketCachekey
end
Now Bar has a blanket_cachekey method which is updated whenever any instance of Bar is created, updated, or destroyed. This key can be used as part of a cache key.
= cache ['bars_selector', Bar.blanket_cachekey] do
f.input :bars, collection: Bar.all
Now whenever any Bar is created, updated, or saved, the cache fragment above will be regenerated on the next hit.
- Fork it
- Create your feature branch (
git checkout -b my-new-feature
) - Commit your changes (
git commit -am 'Add some feature'
) - Push to the branch (
git push origin my-new-feature
) - Create new Pull Request