Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class ArticleSweeper < ActionController::Caching::Sweeper
- observe Article
- def before( controller )
- super
- true # CHECK HERE
- end
- def after_create( article )
- default_expires( article )
- true # AND HERE
- end
- def after_destroy( article )
- default_expires( article )
- true # AND HERE
- end
- def after_update( article )
- default_expires( article )
- expire_fragment( :controller => :articles, :action => :show, :id => "article_#{article.id}" )
- true # AND HERE
- end
- private
- def default_expires( article )
- expire_fragment( :controller => :articles, :action => :index, :type => :all_articles )
- # expire_fragment( :controller => :articles, :action => :rss )
- expire_fragment( :controller => :articles, :action => :projects, :type => :all_articles )
- expire_fragment( :controller => :articles, :action => :show, :id => article.id )
- expire_fragment( :controller => :welcome, :action => :index, :action_suffix => :global_menu )
- expire_fragment( :controller => :articles,
- :action => :by_date,
- :year => article.created_at.year,
- :month => article.created_at.month,
- :type => :all_articles
- )
- end
- end
Add Comment
Please, Sign In to add comment