]> source.dussan.org Git - redmine.git/commitdiff
Adds JS response support to #render_error (#15760).
authorJean-Philippe Lang <jp_lang@yahoo.fr>
Fri, 7 Feb 2014 09:26:27 +0000 (09:26 +0000)
committerJean-Philippe Lang <jp_lang@yahoo.fr>
Fri, 7 Feb 2014 09:26:27 +0000 (09:26 +0000)
git-svn-id: http://svn.redmine.org/redmine/trunk@12855 e93f8b46-1217-0410-a6f0-8f06a7374b81

app/controllers/application_controller.rb
app/views/common/error.js.erb [new file with mode: 0644]

index b297aa738f1866a7bfc8e870a0925ef0ff72e23f..8060c9e960c61c216429c2bbf90acc5cf9254296 100644 (file)
@@ -431,6 +431,10 @@ class ApplicationController < ActionController::Base
       format.html {
         render :template => 'common/error', :layout => use_layout, :status => @status
       }
+      format.js {
+        # Can't use an error status here, browsers wouldn't execute the JS response
+        render :template => 'common/error', :layout => false, :status => 200
+      }
       format.any { head @status }
     end
   end
diff --git a/app/views/common/error.js.erb b/app/views/common/error.js.erb
new file mode 100644 (file)
index 0000000..81d377f
--- /dev/null
@@ -0,0 +1 @@
+alert("<%= raw escape_javascript @message %> (<%= raw escape_javascript @status.to_s %>)");