Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

invert logic to remove nil? and exclude? checks (use ruby rather than…

… AS when possible
  • Loading branch information...
commit 60ae50507d587e3663794fb8bdd0f967e5368695 1 parent 353df48
@tenderlove tenderlove authored
Showing with 6 additions and 6 deletions.
  1. +6 −6 actionpack/lib/action_dispatch/routing/mapper.rb
View
12 actionpack/lib/action_dispatch/routing/mapper.rb
@@ -281,22 +281,22 @@ def default_controller_and_action
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"
Please sign in to comment.
Something went wrong with that request. Please try again.