Skip to content
Browse files

only one nil check on the action variable

  • Loading branch information...
1 parent a729f40 commit 309ff10d7d895ccb822b426dac3fb0a41e1da193 @tenderlove tenderlove committed May 28, 2014
Showing with 8 additions and 10 deletions.
  1. +8 −10 actionpack/lib/action_dispatch/routing/mapper.rb
View
18 actionpack/lib/action_dispatch/routing/mapper.rb
@@ -259,11 +259,16 @@ def default_controller_and_action
end
end
- if action.is_a? Regexp
+ case action
+ when Regexp
hash[:action] = action
+ when String, Symbol
+ hash[:action] = action.to_s
else
- check_action! action
- hash[:action] = action.to_s if action
+ unless segment_keys.include?(:action)
+ message = "Missing :action key on routes definition, please check your routes."
+ raise ArgumentError, message
+ end
end
hash
@@ -289,13 +294,6 @@ def get_controller_and_action(controller, action, to, modyoule)
[controller, action]
end
- def check_action!(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)
return controller if controller =~ /\A[a-z_0-9][a-z_0-9\/]*\z/

0 comments on commit 309ff10

Please sign in to comment.
Something went wrong with that request. Please try again.