Sha256: eb636c91c2149381e18c0902a5f7c35657a169c454830d661a893462f7323a5f
Contents?: true
Size: 1.11 KB
Versions: 3
Compression:
Stored size: 1.11 KB
Contents
class PostSweeper < ActionController::Caching::Sweeper observe Post # This sweeper is going to keep an eye on the Post model # If our sweeper detects that a Post was created call this def after_create(post) expire_cache_for(post) end # If our sweeper detects that a Post was updated call this def after_update(post) expire_cache_for(post) end # If our sweeper detects that a Post was deleted call this def after_destroy(post) expire_cache_for(post) end private def expire_cache_for(record) # Expire the home page expire_action(:controller => 'base', :action => 'site_index') # Expire the footer content expire_action(:controller => 'base', :action => 'footer_content') # Also expire the sitemap expire_action(:controller => 'sitemap', :action => 'index') # Expire the category pages expire_action(:controller => 'categories', :action => 'index') # Also expire the show pages, in case we just edited a blog entry expire_action(:controller => 'posts', :action => 'show', :id => record.to_param, :user_id => record.user.to_param) end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
community_engine-2.3.0 | app/controllers/post_sweeper.rb |
community_engine-2.1.0 | app/controllers/post_sweeper.rb |
community_engine-2.0.0 | app/controllers/post_sweeper.rb |