Use AR callbacks instead of observers (removed in Rails4) for notifications.

git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@12021 e93f8b46-1217-0410-a6f0-8f06a7374b81
This commit is contained in:
Jean-Philippe Lang
2013-07-14 14:26:27 +00:00
parent 010bfc56e1
commit 205eda8b33
16 changed files with 72 additions and 173 deletions
+10
View File
@@ -30,6 +30,8 @@ class Document < ActiveRecord::Base
validates_presence_of :project, :title, :category
validates_length_of :title, :maximum => 60
after_create :send_notification
scope :visible, lambda {|*args|
includes(:project).where(Project.allowed_to_condition(args.shift || User.current, :view_documents, *args))
}
@@ -54,4 +56,12 @@ class Document < ActiveRecord::Base
end
@updated_on
end
private
def send_notification
if Setting.notified_events.include?('document_added')
Mailer.document_added(self).deliver
end
end
end