diff options
author | Jean-Philippe Lang <jp_lang@yahoo.fr> | 2013-07-14 14:26:27 +0000 |
---|---|---|
committer | Jean-Philippe Lang <jp_lang@yahoo.fr> | 2013-07-14 14:26:27 +0000 |
commit | 205eda8b33d69defecedf2d246858a46d3d1d7c0 (patch) | |
tree | 4aeb58588ec0fa06ca385fe032168d336970fe55 /app/models/wiki_content.rb | |
parent | 010bfc56e15f442e4e597ddc9c436361c61b1e7a (diff) | |
download | redmine-205eda8b33d69defecedf2d246858a46d3d1d7c0.tar.gz redmine-205eda8b33d69defecedf2d246858a46d3d1d7c0.zip |
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
Diffstat (limited to 'app/models/wiki_content.rb')
-rw-r--r-- | app/models/wiki_content.rb | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/app/models/wiki_content.rb b/app/models/wiki_content.rb index a9ed005bc..20295e9d5 100644 --- a/app/models/wiki_content.rb +++ b/app/models/wiki_content.rb @@ -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 |