aboutsummaryrefslogtreecommitdiffstats
path: root/actionpack/lib/action_dispatch/routing
diff options
context:
space:
mode:
authorAaron Patterson <aaron.patterson@gmail.com>2015-08-11 14:49:08 -0700
committerAaron Patterson <aaron.patterson@gmail.com>2015-08-11 14:49:19 -0700
commit763dd50a7668c8c291ed454d12fc90d4e935329c (patch)
treef45770ea06e9ddb818646868e3214adfaf94bf8c /actionpack/lib/action_dispatch/routing
parent0c3f8e3f0248c033119c81d4590c8de2ac46f174 (diff)
downloadrails-763dd50a7668c8c291ed454d12fc90d4e935329c.tar.gz
rails-763dd50a7668c8c291ed454d12fc90d4e935329c.tar.bz2
rails-763dd50a7668c8c291ed454d12fc90d4e935329c.zip
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
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: