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:
parent
8f362558b6
commit
049b35edb0
|
@ -39,6 +39,7 @@ class Message < ActiveRecord::Base
|
||||||
attr_protected :locked, :sticky
|
attr_protected :locked, :sticky
|
||||||
validates_presence_of :board, :subject, :content
|
validates_presence_of :board, :subject, :content
|
||||||
validates_length_of :subject, :maximum => 255
|
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_create :add_author_as_watcher, :update_parent_last_reply
|
||||||
after_update :update_messages_board
|
after_update :update_messages_board
|
||||||
|
@ -51,7 +52,7 @@ class Message < ActiveRecord::Base
|
||||||
!user.nil? && user.allowed_to?(:view_messages, project)
|
!user.nil? && user.allowed_to?(:view_messages, project)
|
||||||
end
|
end
|
||||||
|
|
||||||
def validate_on_create
|
def cannot_reply_to_locked_topic
|
||||||
# Can not reply to a locked topic
|
# Can not reply to a locked topic
|
||||||
errors.add_to_base 'Topic is locked' if root.locked? && self != root
|
errors.add_to_base 'Topic is locked' if root.locked? && self != root
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in New Issue