Guest User

Untitled

a guest
May 24th, 2018
104
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.23 KB | None | 0 0
  1. class ArticleSweeper < ActionController::Caching::Sweeper
  2. observe Article
  3.  
  4. def before( controller )
  5. super
  6. true # CHECK HERE
  7. end
  8.  
  9. def after_create( article )
  10. default_expires( article )
  11. true # AND HERE
  12. end
  13.  
  14. def after_destroy( article )
  15. default_expires( article )
  16. true # AND HERE
  17. end
  18.  
  19. def after_update( article )
  20. default_expires( article )
  21.  
  22. expire_fragment( :controller => :articles, :action => :show, :id => "article_#{article.id}" )
  23. true # AND HERE
  24. end
  25.  
  26. private
  27. def default_expires( article )
  28. expire_fragment( :controller => :articles, :action => :index, :type => :all_articles )
  29. # expire_fragment( :controller => :articles, :action => :rss )
  30. expire_fragment( :controller => :articles, :action => :projects, :type => :all_articles )
  31.  
  32. expire_fragment( :controller => :articles, :action => :show, :id => article.id )
  33. expire_fragment( :controller => :welcome, :action => :index, :action_suffix => :global_menu )
  34.  
  35. expire_fragment( :controller => :articles,
  36. :action => :by_date,
  37. :year => article.created_at.year,
  38. :month => article.created_at.month,
  39. :type => :all_articles
  40. )
  41. end
  42. end
Add Comment
Please, Sign In to add comment