提交 a842c5c1 编写于 作者: A Alex Robbin

allow URL helpers to work with optional scopes

上级 4c2aaca4
* Fixed usage of optional scopes in URL helpers.
*Alex Robbin*
* Fixed handling of positional url helper arguments when `format: false`.
Fixes #17819.
......
......@@ -293,7 +293,7 @@ def handle_positional_args(controller_options, inner_options, args, result, path
path_params -= result.keys
end
path_params.each { |param|
result[param] = inner_options[param] || args.shift
result[param] = inner_options.fetch(param) { args.shift }
}
end
......
......@@ -160,6 +160,18 @@ def call(env)
assert_equal '/foo/1/bar/2', url_helpers.foo_bar_path(2, foo_id: 1)
end
test "having an optional scope with resources" do
draw do
scope "(/:foo)" do
resources :users
end
end
assert_equal '/users/1', url_helpers.user_path(1)
assert_equal '/users/1', url_helpers.user_path(1, foo: nil)
assert_equal '/a/users/1', url_helpers.user_path(1, foo: 'a')
end
test "stringified controller and action keys are properly symbolized" do
draw do
root 'foo#bar'
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册