1
0
Fork 0
mirror of https://github.com/rails/rails.git synced 2022-11-09 12:12:34 -05:00

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.
This commit is contained in:
schneems 2013-05-16 16:21:53 -05:00 committed by Rafael Mendonça França
parent 156e2e3fd8
commit ba0695f48a
2 changed files with 12 additions and 0 deletions

View file

@ -218,6 +218,7 @@ module ActionDispatch
keys -= t.url_options.keys if t.respond_to?(:url_options) keys -= t.url_options.keys if t.respond_to?(:url_options)
keys -= options.keys keys -= options.keys
end end
keys -= inner_options.keys
result.merge!(Hash[keys.zip(args)]) result.merge!(Hash[keys.zip(args)])
end end

View file

@ -69,6 +69,17 @@ module ActionDispatch
end end
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 private
def clear! def clear!
@set.clear! @set.clear!