From 1b73d53a1c45933017dd10d2edc506a4982c4c0d Mon Sep 17 00:00:00 2001 From: Aaron Patterson Date: Sat, 8 Aug 2015 16:39:16 -0700 Subject: eliminate assignment in conditional The method we called already has the conditional we need. Just add an else block so that we don't need two tests. --- actionpack/lib/action_dispatch/routing/route_set.rb | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'actionpack/lib/action_dispatch') diff --git a/actionpack/lib/action_dispatch/routing/route_set.rb b/actionpack/lib/action_dispatch/routing/route_set.rb index cc86890c0a..d58293d93b 100644 --- a/actionpack/lib/action_dispatch/routing/route_set.rb +++ b/actionpack/lib/action_dispatch/routing/route_set.rb @@ -35,7 +35,7 @@ module ActionDispatch prepare_params!(params) # Just raise undefined constant errors if a controller was specified as default. - unless controller = controller(params, @raise_on_name_error) + controller = controller(params, @raise_on_name_error) do return [404, {'X-Cascade' => 'pass'}, []] end @@ -57,6 +57,8 @@ module ActionDispatch if params && params.key?(:controller) controller_param = params[:controller] controller_reference(controller_param) + else + yield end rescue NameError => e raise ActionController::RoutingError, e.message, e.backtrace if raise_on_name_error -- cgit v1.2.3