Sha256: f30624317e042d5aea8000cd564e4176892a5f69fe867507e82fb3c5400a0447
Contents?: true
Size: 904 Bytes
Versions: 4
Compression:
Stored size: 904 Bytes
Contents
class PageSweeper < ActionController::Caching::Sweeper observe Page # This sweeper is going to keep an eye on the Page model # If our sweeper detects that a Page was created call this def after_create(page) expire_cache_for(page) end # If our sweeper detects that a Page was updated call this def after_update(page) expire_cache_for(page) end # If our sweeper detects that a Page was deleted call this def after_destroy(page) expire_cache_for(page) end private def expire_cache_for(record) # Expire the home page expire_action(:controller => 'base', :action => 'site_index') # Also expire the sitemap expire_action(:controller => 'sitemap', :action => 'index') # Also expire the show pages, in case we just edited/deleted a page expire_action(:controller => 'pages', :action => 'show', :id => record.to_param) end end
Version data entries
4 entries across 4 versions & 1 rubygems