From 763dd50a7668c8c291ed454d12fc90d4e935329c Mon Sep 17 00:00:00 2001 From: Aaron Patterson Date: Tue, 11 Aug 2015 14:49:08 -0700 Subject: split options hash and pass values down `using_match_shorthand?` doesn't need to know that an options hash exists. Also use this opportunity to make the boolean logic a little more sane --- actionpack/lib/action_dispatch/routing/mapper.rb | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) (limited to 'actionpack/lib/action_dispatch/routing') diff --git a/actionpack/lib/action_dispatch/routing/mapper.rb b/actionpack/lib/action_dispatch/routing/mapper.rb index 56dcd1aaa4..abef307f3c 100644 --- a/actionpack/lib/action_dispatch/routing/mapper.rb +++ b/actionpack/lib/action_dispatch/routing/mapper.rb @@ -1556,7 +1556,7 @@ module ActionDispatch def process_path(options, controller, path, option_path) path_without_format = path.sub(/\(\.:format\)$/, '') - if using_match_shorthand?(path_without_format, options) + if using_match_shorthand?(path_without_format, options[:to], options[:action]) options[:to] ||= path_without_format.gsub(%r{^/}, "").sub(%r{/([^/]*)$}, '#\1') options[:to].tr!("-", "_") end @@ -1564,8 +1564,10 @@ module ActionDispatch decomposed_match(path, controller, options, option_path) end - def using_match_shorthand?(path, options) - path && (options[:to] || options[:action]).nil? && path =~ %r{^/?[-\w]+/[-\w/]+$} + def using_match_shorthand?(path, to, action) + return false if to || action + + path && path =~ %r{^/?[-\w]+/[-\w/]+$} end def decomposed_match(path, controller, options, _path) # :nodoc: -- cgit v1.2.3