From: Jean-Philippe Lang Date: Fri, 7 Feb 2014 09:26:27 +0000 (+0000) Subject: Adds JS response support to #render_error (#15760). X-Git-Tag: 2.5.0~50 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=3d64938adcd4dd9372c0a47aa4f03b065d088279;p=redmine.git Adds JS response support to #render_error (#15760). git-svn-id: http://svn.redmine.org/redmine/trunk@12855 e93f8b46-1217-0410-a6f0-8f06a7374b81 --- diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index b297aa738..8060c9e96 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -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 index 000000000..81d377fe6 --- /dev/null +++ b/app/views/common/error.js.erb @@ -0,0 +1 @@ +alert("<%= raw escape_javascript @message %> (<%= raw escape_javascript @status.to_s %>)");