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:
1 parent
010bfc56e1
commit
205eda8b33
16 files changed
+72
-173
No files matched your search
@@ -33,6 +33,7 @@ class News < ActiveRecord::Base
|
||||
acts_as_watchable
|
||||
|
||||
after_create :add_author_as_watcher
|
||||
after_create :send_notification
|
||||
|
||||
scope :visible, lambda {|*args|
|
||||
includes(:project).where(Project.allowed_to_condition(args.shift || User.current, :view_news, *args))
|
||||
@@ -63,4 +64,10 @@ class News < ActiveRecord::Base
|
||||
def add_author_as_watcher
|
||||
Watcher.create(:watchable => self, :user => author)
|
||||
end
|
||||
|
||||
def send_notification
|
||||
if Setting.notified_events.include?('news_added')
|
||||
Mailer.news_added(self).deliver
|
||||
end
|
||||
end
|
||||
end
|
||||
Reference in new issue
Block a user