@@ -41,6 +41,7 class Message < ActiveRecord::Base | |||||
41 | validates_length_of :subject, :maximum => 255 |
|
41 | validates_length_of :subject, :maximum => 255 | |
42 |
|
42 | |||
43 | after_create :add_author_as_watcher, :update_parent_last_reply |
|
43 | after_create :add_author_as_watcher, :update_parent_last_reply | |
|
44 | after_update :update_messages_board | |||
44 |
|
45 | |||
45 | named_scope :visible, lambda {|*args| { :include => {:board => :project}, |
|
46 | named_scope :visible, lambda {|*args| { :include => {:board => :project}, | |
46 | :conditions => Project.allowed_to_condition(args.shift || User.current, :view_messages, *args) } } |
|
47 | :conditions => Project.allowed_to_condition(args.shift || User.current, :view_messages, *args) } } | |
@@ -61,7 +62,7 class Message < ActiveRecord::Base | |||||
61 | board.reset_counters! |
|
62 | board.reset_counters! | |
62 | end |
|
63 | end | |
63 |
|
64 | |||
64 | def after_update |
|
65 | def update_messages_board | |
65 | if board_id_changed? |
|
66 | if board_id_changed? | |
66 | Message.update_all("board_id = #{board_id}", ["id = ? OR parent_id = ?", root.id, root.id]) |
|
67 | Message.update_all("board_id = #{board_id}", ["id = ? OR parent_id = ?", root.id, root.id]) | |
67 | Board.reset_counters!(board_id_was) |
|
68 | Board.reset_counters!(board_id_was) |
General Comments 0
You need to be logged in to leave comments.
Login now