From 325fc3e864dac4aebc8a0c7a04def1e9b0e9dfdd Mon Sep 17 00:00:00 2001 From: Toks Date: Sat, 3 Jan 2015 14:13:53 -0500 Subject: [PATCH] fixes #2154 --- app/models/note.rb | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/app/models/note.rb b/app/models/note.rb index dac1b090a..0a38d93be 100644 --- a/app/models/note.rb +++ b/app/models/note.rb @@ -144,10 +144,12 @@ class Note < ActiveRecord::Base end def update_post - if Note.where(:is_active => true, :post_id => post_id).exists? - execute_sql("UPDATE posts SET last_noted_at = ? WHERE id = ?", updated_at, post_id) - else - execute_sql("UPDATE posts SET last_noted_at = NULL WHERE id = ?", post_id) + if self.changed? + if Note.where(:is_active => true, :post_id => post_id).exists? + execute_sql("UPDATE posts SET last_noted_at = ? WHERE id = ?", updated_at, post_id) + else + execute_sql("UPDATE posts SET last_noted_at = NULL WHERE id = ?", post_id) + end end end