From 60ae50507d587e3663794fb8bdd0f967e5368695 Mon Sep 17 00:00:00 2001 From: Aaron Patterson Date: Wed, 28 May 2014 15:54:43 -0700 Subject: invert logic to remove nil? and exclude? checks (use ruby rather than AS when possible --- actionpack/lib/action_dispatch/routing/mapper.rb | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'actionpack/lib/action_dispatch') diff --git a/actionpack/lib/action_dispatch/routing/mapper.rb b/actionpack/lib/action_dispatch/routing/mapper.rb index 6b6e27ceb0..e8dd54b3f0 100644 --- a/actionpack/lib/action_dispatch/routing/mapper.rb +++ b/actionpack/lib/action_dispatch/routing/mapper.rb @@ -281,22 +281,22 @@ module ActionDispatch end def check_action!(action) - if action.nil? && segment_keys.exclude?(:action) + unless action || segment_keys.include?(:action) message = "Missing :action key on routes definition, please check your routes." raise ArgumentError, message end end def check_controller!(controller) - if controller.is_a?(String) && controller =~ %r{\A/} - raise ArgumentError, "controller name should not start with a slash" - end - - if controller.nil? && segment_keys.exclude?(:controller) + unless controller || segment_keys.include?(:controller) message = "Missing :controller key on routes definition, please check your routes." raise ArgumentError, message end + if controller.is_a?(String) && controller =~ %r{\A/} + raise ArgumentError, "controller name should not start with a slash" + end + if controller.is_a?(String) && controller !~ /\A[a-z_0-9\/]*\z/ message = "'#{controller}' is not a supported controller name. This can lead to potential routing problems." message << " See http://guides.rubyonrails.org/routing.html#specifying-a-controller-to-use" -- cgit v1.2.3