module ActionController module Rescue def rescue_action_locally(exception) add_variables_to_assigns @template.instance_variable_set("@exception", exception) @template.instance_variable_set("@rescues_path", File.dirname(rescues_path("stub"))) @template.send(:assign_variables_from_controller) @template.instance_variable_set("@contents", @template.render_file(template_path_for_local_rescue(exception), false)) if request.xhr? # Write the error to disk then Send Javascript back f = File.new(File.join(RAILS_ROOT,'public/xhr_error.html'), "wb+") f.puts @template.render_file(rescues_path("layout"), false, {}) f.close render :update do |page| page << %(if(confirm('Error: #{exception.class}. Debug?')) {window.location='/xhr_error.html'}) end else response.content_type = Mime::HTML self.respond_to?(:render_file) ? render_file(rescues_path("layout"), response_code_for_rescue(exception)) : render_for_file(rescues_path("layout"), response_code_for_rescue(exception)) end end end end