fix score updates for favoriting

This commit is contained in:
albert
2013-02-26 22:45:56 -08:00
parent 155974210b
commit 1acfe65499
2 changed files with 35 additions and 2 deletions

View File

@@ -491,6 +491,7 @@ class Post < ActiveRecord::Base
return if favorited_by?(user.id)
append_user_to_fav_string(user.id)
increment!(:fav_count)
increment!(:score) if CurrentUser.is_privileged?
user.add_favorite!(self)
end
@@ -501,6 +502,7 @@ class Post < ActiveRecord::Base
def remove_favorite!(user)
return unless favorited_by?(user.id)
decrement!(:fav_count)
decrement!(:score) if CurrentUser.is_privileged?
delete_user_from_fav_string(user.id)
user.remove_favorite!(self)
end