summaryrefslogtreecommitdiffstats
path: root/app/models/wiki_page.rb
diff options
context:
space:
mode:
authorJean-Philippe Lang <jp_lang@yahoo.fr>2012-11-18 16:01:07 +0000
committerJean-Philippe Lang <jp_lang@yahoo.fr>2012-11-18 16:01:07 +0000
commitf36b3fff60473dec197f17f632213785a6982382 (patch)
tree9d8659f6f9122d7e0a1490a987cd480df1ad3dba /app/models/wiki_page.rb
parent46d27348fd60128b7d220d209f6d9382003aa165 (diff)
downloadredmine-f36b3fff60473dec197f17f632213785a6982382.tar.gz
redmine-f36b3fff60473dec197f17f632213785a6982382.zip
Code cleanup.
git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@10842 e93f8b46-1217-0410-a6f0-8f06a7374b81
Diffstat (limited to 'app/models/wiki_page.rb')
-rw-r--r--app/models/wiki_page.rb15
1 files changed, 15 insertions, 0 deletions
diff --git a/app/models/wiki_page.rb b/app/models/wiki_page.rb
index 17e0a4c4f..c275cd83e 100644
--- a/app/models/wiki_page.rb
+++ b/app/models/wiki_page.rb
@@ -173,6 +173,21 @@ class WikiPage < ActiveRecord::Base
self.parent = parent_page
end
+ # Saves the page and its content if text was changed
+ def save_with_content
+ ret = nil
+ transaction do
+ if new_record?
+ # Rails automatically saves associated content
+ ret = save
+ else
+ ret = save && (content.text_changed? ? content.save : true)
+ end
+ raise ActiveRecord::Rollback unless ret
+ end
+ ret
+ end
+
protected
def validate_parent_title