Commit e062c05f4c02c496b219e7076c79657617aa4dad
Committed by
Daniela Feitosa
1 parent
0df8e456
Exists in
master
and in
29 other branches
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 +10,16 @@ class ArticleSweeper < ActiveRecord::Observer | ||
10 | expire_caches(article) | 10 | expire_caches(article) |
11 | end | 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 | protected | 19 | protected |
14 | 20 | ||
15 | def expire_caches(article) | 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 | blocks = article.profile.blocks | 23 | blocks = article.profile.blocks |
18 | blocks += article.profile.environment.blocks if article.profile.environment | 24 | blocks += article.profile.environment.blocks if article.profile.environment |
19 | blocks = blocks.select{|b|[RecentDocumentsBlock, BlogArchivesBlock].any?{|c| b.kind_of?(c)}} | 25 | blocks = blocks.select{|b|[RecentDocumentsBlock, BlogArchivesBlock].any?{|c| b.kind_of?(c)}} |