fixes #952
This commit is contained in:
@@ -20,6 +20,7 @@ class Favorite < ActiveRecord::Base
|
||||
User.update_all("favorite_count = favorite_count + 1", {:id => user.id})
|
||||
user.favorite_count += 1
|
||||
post.fav_count += 1
|
||||
post.score += 1
|
||||
end
|
||||
|
||||
def self.remove(post, user)
|
||||
@@ -31,5 +32,6 @@ class Favorite < ActiveRecord::Base
|
||||
User.update_all("favorite_count = favorite_count - 1", {:id => user.id})
|
||||
user.favorite_count -= 1
|
||||
post.fav_count -= 1
|
||||
post.score -= 1
|
||||
end
|
||||
end
|
||||
|
||||
@@ -639,8 +639,10 @@ class Post < ActiveRecord::Base
|
||||
if can_be_voted_by?(CurrentUser.user)
|
||||
if score == "up"
|
||||
Post.update_all("score = score + 1, up_score = up_score + 1", {:id => id})
|
||||
self.score += 1
|
||||
elsif score == "down"
|
||||
Post.update_all("score = score - 1, down_score = down_score - 1", {:id => id})
|
||||
self.score -= 1
|
||||
end
|
||||
|
||||
votes.create(:score => score)
|
||||
|
||||
Reference in New Issue
Block a user