This commit is contained in:
Toks
2015-01-03 14:13:53 -05:00
parent 7f60201a21
commit 325fc3e864

View File

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