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:
@@ -26,6 +26,8 @@ class WikiContent < ActiveRecord::Base
|
||||
|
||||
acts_as_versioned
|
||||
|
||||
after_save :send_notification
|
||||
|
||||
def visible?(user=User.current)
|
||||
page.visible?(user)
|
||||
end
|
||||
@@ -145,4 +147,19 @@ class WikiContent < ActiveRecord::Base
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def send_notification
|
||||
# new_record? returns false in after_save callbacks
|
||||
if id_changed?
|
||||
if Setting.notified_events.include?('wiki_content_added')
|
||||
Mailer.wiki_content_added(self).deliver
|
||||
end
|
||||
elsif text_changed?
|
||||
if Setting.notified_events.include?('wiki_content_updated')
|
||||
Mailer.wiki_content_updated(self).deliver
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user