Rails3: model: replace deprecated 'after_update' method at Message model

git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@7456 e93f8b46-1217-0410-a6f0-8f06a7374b81
This commit is contained in:
Toshi MARUYAMA 2011-09-22 15:41:25 +00:00
parent f5df743446
commit c23052aa08
1 changed files with 2 additions and 1 deletions

View File

@ -41,6 +41,7 @@ class Message < ActiveRecord::Base
validates_length_of :subject, :maximum => 255
after_create :add_author_as_watcher, :update_parent_last_reply
after_update :update_messages_board
named_scope :visible, lambda {|*args| { :include => {:board => :project},
:conditions => Project.allowed_to_condition(args.shift || User.current, :view_messages, *args) } }
@ -61,7 +62,7 @@ class Message < ActiveRecord::Base
board.reset_counters!
end
def after_update
def update_messages_board
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)