This commit is contained in:
r888888888
2013-06-10 18:12:57 -07:00
parent df7bbcd4d1
commit 61f8c38d34
2 changed files with 4 additions and 0 deletions

View File

@@ -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

View File

@@ -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)