diff options
Diffstat (limited to 'app/models/wiki_page.rb')
-rw-r--r-- | app/models/wiki_page.rb | 15 |
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 |