diff --git a/app/models/message.rb b/app/models/message.rb index f7b3798f7b..c7e1b6b1c4 100644 --- a/app/models/message.rb +++ b/app/models/message.rb @@ -47,6 +47,7 @@ class Message < ActiveRecord::Base after_create :add_author_as_watcher after_create :update_last_reply_in_parent + after_update :update_ancestors after_destroy :reset_counters scope :visible, lambda {|*args| { :include => {:board => :project}, @@ -76,7 +77,7 @@ class Message < ActiveRecord::Base board.reset_counters! end - def after_update + def update_ancestors if board_id_changed? Message.update_all("board_id = #{board_id}", ["id = ? OR parent_id = ?", root.id, root.id]) Board.reset_counters!(board_id_was)