Commit 040f7d1e1de54b0b63e90fb93b3b0debe7af337f

Authored by Rodrigo Souto
1 parent 1ddcb30d

Sweeping cache of article new parent and previous parent when article is moved

Showing 1 changed file with 7 additions and 1 deletions   Show diff stats
app/sweepers/article_sweeper.rb
... ... @@ -10,10 +10,16 @@ class ArticleSweeper < ActiveRecord::Observer
10 10 expire_caches(article)
11 11 end
12 12  
  13 + def before_update(article)
  14 + if article.parent_id_change
  15 + Article.find(article.parent_id_was).touch if article.parent_id_was
  16 + end
  17 + end
  18 +
13 19 protected
14 20  
15 21 def expire_caches(article)
16   - article.hierarchy.each { |a| a.touch if a != article }
  22 + article.hierarchy(true).each { |a| a.touch if a != article }
17 23 blocks = article.profile.blocks
18 24 blocks += article.profile.environment.blocks if article.profile.environment
19 25 blocks = blocks.select{|b|[RecentDocumentsBlock, BlogArchivesBlock].any?{|c| b.kind_of?(c)}}
... ...