aboutsummaryrefslogtreecommitdiffstats
path: root/actionpack/lib/action_dispatch/routing
diff options
context:
space:
mode:
Diffstat (limited to 'actionpack/lib/action_dispatch/routing')
-rw-r--r--actionpack/lib/action_dispatch/routing/mapper.rb8
1 files changed, 5 insertions, 3 deletions
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: