From 9dfb8aa33e2bcae5f414757831615f931c0a2a05 Mon Sep 17 00:00:00 2001 From: r888888888 Date: Thu, 23 May 2013 17:26:20 -0700 Subject: [PATCH] fixes #1614 --- app/models/forum_post.rb | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/app/models/forum_post.rb b/app/models/forum_post.rb index c8755205c..b2c4a3da5 100644 --- a/app/models/forum_post.rb +++ b/app/models/forum_post.rb @@ -90,16 +90,17 @@ class ForumPost < ActiveRecord::Base def update_topic_updated_at_on_create if topic - topic.updater_id = CurrentUser.id - topic.response_count = topic.response_count + 1 - topic.save + # need to do this to bypass the topic's original post from getting touched + ForumTopic.update_all(["updater_id = ?, response_count = response_count + 1, updated_at = ?", CurrentUser.id, Time.now], {:id => topic.id}) end end def update_topic_updated_at_on_destroy max = ForumPost.where(:topic_id => topic.id).maximum(:updated_at) if max - topic.update_column(:updated_at, max) + ForumTopic.update_all(["response_count = response_count - 1, updated_at = ?", max], {:id => topic.id}) + else + ForumTopic.update_all(["response_count = response_count - 1"], {:id => topic.id}) end end