RailsCasts Pro episodes are now free!
Learn more or hide this
There is a newer version of this episode, see the revised episode.
Resources
caches_page :dynamic_states
config.action_controller.perform_caching = true
config.load_paths << "#{RAILS_ROOT}/app/sweepers"
class StateSweeper < ActionController::Caching::Sweeper observe State def after_save(state) expire_cache(state) end def after_destroy(state) expire_cache(state) end def expire_cache(state) expire_page :controller => 'javascripts', :action => 'dynamic_states', :format => 'js' end end
cache_sweeper :state_sweeper, :only => [:create, :update, :destroy]