From 890e11f532ca804cf3f124707e0f0ba7c288d4e1 Mon Sep 17 00:00:00 2001 From: r888888888 Date: Mon, 6 May 2013 13:33:04 -0700 Subject: [PATCH] potential fix for #1500 --- app/models/favorite.rb | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/app/models/favorite.rb b/app/models/favorite.rb index 6ffd664f9..82f432018 100644 --- a/app/models/favorite.rb +++ b/app/models/favorite.rb @@ -13,9 +13,7 @@ class Favorite < ActiveRecord::Base Post.update_all("fav_count = fav_count + 1", "id = #{post.id}") Post.update_all("score = score + 1", "id = #{post.id}") if user.is_gold? post.append_user_to_fav_string(user.id) - user.add_favorite!(post) - user.increment!(:favorite_count) - post.add_favorite!(user) + User.update_all("favorite_count = favorite_count + 1", "id = #{user.id}") end def self.remove(post, user) @@ -24,8 +22,6 @@ class Favorite < ActiveRecord::Base Post.update_all("fav_count = fav_count - 1", "id = #{post.id}") Post.update_all("score = score - 1", "id = #{post.id}") if user.is_gold? post.delete_user_from_fav_string(user.id) - user.remove_favorite!(post) - user.decrement!(:favorite_count) - post.remove_favorite!(user) + User.update_all("favorite_count = favorite_count - 1", "id = #{user.id}") end end