diff options
author | Aaron Patterson <aaron.patterson@gmail.com> | 2014-05-28 16:28:38 -0700 |
---|---|---|
committer | Aaron Patterson <aaron.patterson@gmail.com> | 2014-05-28 16:28:38 -0700 |
commit | b27a3aff35bf2a7515d4236afe191a7c63481a23 (patch) | |
tree | e2e0ff27208a9b036f3f5d8b7393861aa27d53e1 /actionpack/lib | |
parent | 8d309832df4a32f3bebbbc7ceae800876cef1174 (diff) | |
download | rails-b27a3aff35bf2a7515d4236afe191a7c63481a23.tar.gz rails-b27a3aff35bf2a7515d4236afe191a7c63481a23.tar.bz2 rails-b27a3aff35bf2a7515d4236afe191a7c63481a23.zip |
only do one nil check against the controller
Diffstat (limited to 'actionpack/lib')
-rw-r--r-- | actionpack/lib/action_dispatch/routing/mapper.rb | 18 |
1 files changed, 9 insertions, 9 deletions
diff --git a/actionpack/lib/action_dispatch/routing/mapper.rb b/actionpack/lib/action_dispatch/routing/mapper.rb index aaf5563dce..5027425d6b 100644 --- a/actionpack/lib/action_dispatch/routing/mapper.rb +++ b/actionpack/lib/action_dispatch/routing/mapper.rb @@ -250,8 +250,14 @@ module ActionDispatch if controller.is_a? Regexp hash[:controller] = controller else - check_controller! controller - hash[:controller] = controller.to_s if controller + if controller + hash[:controller] = check_controller!(controller).to_s + else + unless segment_keys.include?(:controller) + message = "Missing :controller key on routes definition, please check your routes." + raise ArgumentError, message + end + end end if action.is_a? Regexp @@ -292,13 +298,7 @@ module ActionDispatch end def check_controller!(controller) - unless controller || segment_keys.include?(:controller) - message = "Missing :controller key on routes definition, please check your routes." - raise ArgumentError, message - end - - return unless controller - return if controller =~ /\A[a-z_0-9][a-z_0-9\/]*\z/ + return controller if controller =~ /\A[a-z_0-9][a-z_0-9\/]*\z/ if controller =~ %r{\A/} message = "controller name should not start with a slash" |