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:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user