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

git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@7555 e93f8b46-1217-0410-a6f0-8f06a7374b81
This commit is contained in:
Toshi MARUYAMA 2011-10-01 01:11:39 +00:00
parent 8f362558b6
commit 049b35edb0
1 changed files with 2 additions and 1 deletions

View File

@ -39,6 +39,7 @@ class Message < ActiveRecord::Base
attr_protected :locked, :sticky
validates_presence_of :board, :subject, :content
validates_length_of :subject, :maximum => 255
validate :cannot_reply_to_locked_topic, :on => :create
after_create :add_author_as_watcher, :update_parent_last_reply
after_update :update_messages_board
@ -51,7 +52,7 @@ class Message < ActiveRecord::Base
!user.nil? && user.allowed_to?(:view_messages, project)
end
def validate_on_create
def cannot_reply_to_locked_topic
# Can not reply to a locked topic
errors.add_to_base 'Topic is locked' if root.locked? && self != root
end