diff --git a/railties/CHANGELOG b/railties/CHANGELOG index f88f1060159eae087139249ac5defbc022704553..877087cbb2089cac22ff3fa2c7d756b0b5a3e39e 100644 --- a/railties/CHANGELOG +++ b/railties/CHANGELOG @@ -1,5 +1,7 @@ *SVN* +* Fixed the failsafe response so it uses either the current recognized controller or ApplicationController. [Rick Olson] + * Make sure script/reaper only reaps dispatcher pids by default, and not the spawner's pid. [Jamis Buck] * Fix script/plugin about so it uses about.yml and not meta.yml. [James Adam] diff --git a/railties/lib/dispatcher.rb b/railties/lib/dispatcher.rb index f43dc9f4c8d20cf9c94da11feaaade7c0305a0f5..f4cb52b3b7c289cccb02ad2551a3de7805b23d57 100644 --- a/railties/lib/dispatcher.rb +++ b/railties/lib/dispatcher.rb @@ -32,14 +32,17 @@ class << self # own CGI object be sure to handle the exceptions it raises on multipart # requests (EOFError and ArgumentError). def dispatch(cgi = nil, session_options = ActionController::CgiRequest::DEFAULT_SESSION_OPTIONS, output = $stdout) + controller = nil if cgi ||= new_cgi(output) request, response = ActionController::CgiRequest.new(cgi, session_options), ActionController::CgiResponse.new(cgi) prepare_application - ActionController::Routing::Routes.recognize(request).process(request, response).out(output) + controller = ActionController::Routing::Routes.recognize(request) + controller.process(request, response).out(output) end rescue Object => exception failsafe_response(output, '500 Internal Server Error', exception) do - ActionController.process_with_exception(request, response, exception).out(output) + controller ||= const_defined?(:ApplicationController) ? ApplicationController : ActionController::Base + controller.process_with_exception(request, response, exception).out(output) end ensure # Do not give a failsafe response here.