aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAaron Patterson <aaron.patterson@gmail.com>2014-05-28 15:54:43 -0700
committerAaron Patterson <aaron.patterson@gmail.com>2014-05-28 15:54:43 -0700
commit60ae50507d587e3663794fb8bdd0f967e5368695 (patch)
tree71e52be94ba4e55e36c27d1879134a645139984b
parent353df48a341953b1bf457aa6f871a6054d6f64ba (diff)
downloadrails-60ae50507d587e3663794fb8bdd0f967e5368695.tar.gz
rails-60ae50507d587e3663794fb8bdd0f967e5368695.tar.bz2
rails-60ae50507d587e3663794fb8bdd0f967e5368695.zip
invert logic to remove nil? and exclude? checks (use ruby rather than AS when possible
-rw-r--r--actionpack/lib/action_dispatch/routing/mapper.rb12
1 files changed, 6 insertions, 6 deletions
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"