aboutsummaryrefslogtreecommitdiffstats
path: root/actionpack
diff options
context:
space:
mode:
authorschneems <richard.schneeman@gmail.com>2013-05-16 16:21:53 -0500
committerRafael Mendonça França <rafaelmfranca@gmail.com>2013-05-16 18:42:15 -0300
commitba0695f48a28d34a9ee4d8da7ec61e15ce90a910 (patch)
tree9080f48f7cc33c68823907015b6796f17e7f524e /actionpack
parent156e2e3fd83ea6aa96a92149fefab37b4d6fdbf8 (diff)
downloadrails-ba0695f48a28d34a9ee4d8da7ec61e15ce90a910.tar.gz
rails-ba0695f48a28d34a9ee4d8da7ec61e15ce90a910.tar.bz2
rails-ba0695f48a28d34a9ee4d8da7ec61e15ce90a910.zip
Fix named routing regression from 3.2.13
When named route that is nested is used in 3.2.13 Example `routes.rb`: ``` resources :nested do resources :builder, :controller => 'nested/builder' end ``` In 3.2.12 and 3.2.12 this named route would work: ``` nested_builder_path(:last_step, :nested_id => "foo") ``` Generating a url that looks like `/nested/foo/builder/last_step`. This PR fixes the regression when building urls via the optimized helper. Any explicit keys set in the options are removed from the list of implicitly mapped keys. Not sure if this is exactly how the original version worked, but this fixes this use case regression.
Diffstat (limited to 'actionpack')
-rw-r--r--actionpack/lib/action_dispatch/routing/route_set.rb1
-rw-r--r--actionpack/test/dispatch/routing/route_set_test.rb11
2 files changed, 12 insertions, 0 deletions
diff --git a/actionpack/lib/action_dispatch/routing/route_set.rb b/actionpack/lib/action_dispatch/routing/route_set.rb
index 342b6ec23d..3ae9f92c0b 100644
--- a/actionpack/lib/action_dispatch/routing/route_set.rb
+++ b/actionpack/lib/action_dispatch/routing/route_set.rb
@@ -218,6 +218,7 @@ module ActionDispatch
keys -= t.url_options.keys if t.respond_to?(:url_options)
keys -= options.keys
end
+ keys -= inner_options.keys
result.merge!(Hash[keys.zip(args)])
end
diff --git a/actionpack/test/dispatch/routing/route_set_test.rb b/actionpack/test/dispatch/routing/route_set_test.rb
index d57b1a5637..0e488d2b88 100644
--- a/actionpack/test/dispatch/routing/route_set_test.rb
+++ b/actionpack/test/dispatch/routing/route_set_test.rb
@@ -69,6 +69,17 @@ module ActionDispatch
end
end
+ test "explicit keys win over implicit keys" do
+ draw do
+ resources :foo do
+ resources :bar, to: SimpleApp.new('foo#show')
+ end
+ end
+
+ assert_equal '/foo/1/bar/2', url_helpers.foo_bar_path(1, 2)
+ assert_equal '/foo/1/bar/2', url_helpers.foo_bar_path(2, foo_id: 1)
+ end
+
private
def clear!
@set.clear!