Commit 7986c24868b71d18388362768574c88b3aab4ef7
Exists in
staging
and in
7 other branches
Merge branch 'following' into staging
Showing
1 changed file
with
8 additions
and
0 deletions
Show diff stats
app/models/article_follower.rb
... | ... | @@ -2,4 +2,12 @@ class ArticleFollower < ActiveRecord::Base |
2 | 2 | attr_accessible :article_id, :person_id, :since |
3 | 3 | belongs_to :article, :counter_cache => :followers_count |
4 | 4 | belongs_to :person |
5 | + | |
6 | + after_create do |article_follower| | |
7 | + ArticleFollower.update_cache_counter(:followers_count, article_follower.article, 1) | |
8 | + end | |
9 | + | |
10 | + after_destroy do |article_follower| | |
11 | + ArticleFollower.update_cache_counter(:followers_count, article_follower.article, -1) | |
12 | + end | |
5 | 13 | end | ... | ... |