]> source.dussan.org Git - redmine.git/commitdiff
Rescue RecordNotSaved in #save_with_content.
authorJean-Philippe Lang <jp_lang@yahoo.fr>
Wed, 3 Dec 2014 20:22:46 +0000 (20:22 +0000)
committerJean-Philippe Lang <jp_lang@yahoo.fr>
Wed, 3 Dec 2014 20:22:46 +0000 (20:22 +0000)
git-svn-id: http://svn.redmine.org/redmine/trunk@13696 e93f8b46-1217-0410-a6f0-8f06a7374b81

app/controllers/wiki_controller.rb
app/models/wiki_page.rb

index 5ce55f2ce0009633fadbb0f6090dcda0b4cc6202..a7ad964e72c13e1217046039e6a6bd50b32ff7af 100644 (file)
@@ -185,11 +185,6 @@ class WikiController < ApplicationController
       }
       format.api { render_api_head :conflict }
     end
-  rescue ActiveRecord::RecordNotSaved
-    respond_to do |format|
-      format.html { render :action => 'edit' }
-      format.api { render_validation_errors(@content) }
-    end
   end
 
   # rename a page
index 9d68de2b6ae464e15b724904108f72451f2f0c01..61e78873da4ba6b891d1c5d164ad51c9032226ef 100644 (file)
@@ -216,13 +216,18 @@ class WikiPage < ActiveRecord::Base
   end
 
   # Saves the page and its content if text was changed
+  # Return true if the page was saved
   def save_with_content(content)
     ret = nil
     transaction do
       ret = save
       if content.text_changed?
-        self.content = content
-        ret = ret && content.changed?
+        begin
+          self.content = content
+          ret = ret && content.changed?
+        rescue ActiveRecord::RecordNotSaved
+          ret = false
+        end
       end
       raise ActiveRecord::Rollback unless ret
     end