diff options
author | Rafael Mendonça França <rafaelmfranca@gmail.com> | 2015-10-10 14:54:35 -0300 |
---|---|---|
committer | Rafael Mendonça França <rafaelmfranca@gmail.com> | 2015-10-10 14:54:35 -0300 |
commit | c61826eebcecd62e021cda4086dbcc1497820ac1 (patch) | |
tree | 106853ed591a650742fa26259e3924878abf5b88 /actionpack/lib | |
parent | 0450642c27af3af35b449208b21695fd55c30f90 (diff) | |
parent | 4db921a8e7dff22eec026e809c39567db6a9ee32 (diff) | |
download | rails-c61826eebcecd62e021cda4086dbcc1497820ac1.tar.gz rails-c61826eebcecd62e021cda4086dbcc1497820ac1.tar.bz2 rails-c61826eebcecd62e021cda4086dbcc1497820ac1.zip |
Merge pull request #20940 from rafaelsales/allow-multiple-root-routes
Allow multiple `root` routes in same scope level
Diffstat (limited to 'actionpack/lib')
-rw-r--r-- | actionpack/lib/action_dispatch/routing/mapper.rb | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/actionpack/lib/action_dispatch/routing/mapper.rb b/actionpack/lib/action_dispatch/routing/mapper.rb index 2f1c2afb91..921cda91ee 100644 --- a/actionpack/lib/action_dispatch/routing/mapper.rb +++ b/actionpack/lib/action_dispatch/routing/mapper.rb @@ -402,7 +402,8 @@ module ActionDispatch # because this means it will be matched first. As this is the most popular route # of most Rails applications, this is beneficial. def root(options = {}) - match '/', { :as => :root, :via => :get }.merge!(options) + name = has_named_route?(:root) ? nil : :root + match '/', { as: name, via: :get }.merge!(options) end # Matches a url pattern to one or more routes. @@ -1867,7 +1868,7 @@ to this: # and return nil in case it isn't. Otherwise, we pass the invalid name # forward so the underlying router engine treats it and raises an exception. if as.nil? - candidate unless candidate !~ /\A[_a-z]/i || @set.named_routes.key?(candidate) + candidate unless candidate !~ /\A[_a-z]/i || has_named_route?(candidate) else candidate end |