From 702965c1b724852afb08e93df64dd65dbcf762d4 Mon Sep 17 00:00:00 2001 From: Aaron Patterson Date: Tue, 25 Aug 2015 15:50:38 -0700 Subject: always return a controller class from the `controller_class` method now the caller can just treat it like a regular controller even though it will return a 404 --- actionpack/lib/action_dispatch/http/request.rb | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) (limited to 'actionpack/lib/action_dispatch/http') diff --git a/actionpack/lib/action_dispatch/http/request.rb b/actionpack/lib/action_dispatch/http/request.rb index a3c6f015d9..e6387768de 100644 --- a/actionpack/lib/action_dispatch/http/request.rb +++ b/actionpack/lib/action_dispatch/http/request.rb @@ -68,16 +68,23 @@ module ActionDispatch end end + PASS_NOT_FOUND = Class.new { # :nodoc: + def self.action(_); self; end + def self.call(_); [404, {'X-Cascade' => 'pass'}, []]; end + } + def controller_class check_path_parameters! params = path_parameters - controller_param = params[:controller].underscore if params.key?(:controller) - params[:action] ||= 'index' - - yield unless controller_param - const_name = "#{controller_param.camelize}Controller" - ActiveSupport::Dependencies.constantize(const_name) + if params.key?(:controller) + controller_param = params[:controller].underscore + params[:action] ||= 'index' + const_name = "#{controller_param.camelize}Controller" + ActiveSupport::Dependencies.constantize(const_name) + else + PASS_NOT_FOUND + end end def key?(key) -- cgit v1.2.3