aboutsummaryrefslogtreecommitdiffstats
path: root/actionpack/lib/action_dispatch/routing/mapper.rb
diff options
context:
space:
mode:
authorPiotr Jakubowski <piotrj@gmail.com>2016-06-27 21:02:19 +0200
committerPiotr Jakubowski <piotrj@gmail.com>2016-06-28 20:05:51 +0200
commita0b1912fb077d47e1977cf1b38b884651756d853 (patch)
tree1cdbf5b88c3bb3767e559571d5152a3a7af1c9a9 /actionpack/lib/action_dispatch/routing/mapper.rb
parent754e5bdf8713b95c2bb9d2ab4656fd240da12181 (diff)
downloadrails-a0b1912fb077d47e1977cf1b38b884651756d853.tar.gz
rails-a0b1912fb077d47e1977cf1b38b884651756d853.tar.bz2
rails-a0b1912fb077d47e1977cf1b38b884651756d853.zip
Fix setting route's to in a scope
Fixes #25488 97d7dc4 introduced a regression that resulted in ArgumentError when to was in options of the scope and not of particular route.
Diffstat (limited to 'actionpack/lib/action_dispatch/routing/mapper.rb')
-rw-r--r--actionpack/lib/action_dispatch/routing/mapper.rb10
1 files changed, 9 insertions, 1 deletions
diff --git a/actionpack/lib/action_dispatch/routing/mapper.rb b/actionpack/lib/action_dispatch/routing/mapper.rb
index 40b6500553..e2cf75da3a 100644
--- a/actionpack/lib/action_dispatch/routing/mapper.rb
+++ b/actionpack/lib/action_dispatch/routing/mapper.rb
@@ -1062,6 +1062,10 @@ module ActionDispatch
def merge_shallow_scope(parent, child) #:nodoc:
child ? true : false
end
+
+ def merge_to_scope(parent, child)
+ child
+ end
end
# Resource routing allows you to quickly declare all of the common routes
@@ -1582,6 +1586,10 @@ module ActionDispatch
raise ArgumentError, "Unknown scope #{on.inspect} given to :on"
end
+ if @scope[:to]
+ options[:to] ||= @scope[:to]
+ end
+
if @scope[:controller] && @scope[:action]
options[:to] ||= "#{@scope[:controller]}##{@scope[:action]}"
end
@@ -2021,7 +2029,7 @@ to this:
class Scope # :nodoc:
OPTIONS = [:path, :shallow_path, :as, :shallow_prefix, :module,
:controller, :action, :path_names, :constraints,
- :shallow, :blocks, :defaults, :via, :format, :options]
+ :shallow, :blocks, :defaults, :via, :format, :options, :to]
RESOURCE_SCOPES = [:resource, :resources]
RESOURCE_METHOD_SCOPES = [:collection, :member, :new]