提交 a75d273e 编写于 作者: M Michael Koziarski

Allow additional parameters to be passed to named route helpers when using...

Allow additional parameters to be passed to named route helpers when using positional arguments.  Closes #8930 [ian.w.white@gmail.com]


git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@7411 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
上级 bc41e8a4
*SVN*
* Allow additional parameters to be passed to named route helpers when using positional arguments. Closes #8930 [ian.w.white@gmail.com]
* Make render :partial work with a :collection of Hashes, previously this wasn't possible due to backwards compatibility restrictions. [lifofifo]
* request.host works with IPv6 addresses. #9458 [yuya]
......
......@@ -1160,10 +1160,17 @@ def #{selector}(*args)
# instead of
#
# foo_url(:bar => bar, :baz => baz, :bang => bang)
args.zip(#{segment_keys.inspect}).inject({}) do |h, (v, k)|
#
# Also allow options hash, so you can do
#
# foo_url(bar, baz, bang, :sort_by => 'baz')
#
options = args.last.is_a?(Hash) ? args.pop : {}
args = args.zip(#{segment_keys.inspect}).inject({}) do |h, (v, k)|
h[k] = v
h
end
options.merge(args)
end
url_for(#{hash_access_method}(opts))
......
......@@ -1504,6 +1504,18 @@ def test_namd_route_url_method_with_ordered_parameters
controller.send(:multi_url, 7, "hello", 5)
end
def test_named_route_url_method_with_ordered_parameters_and_hash
controller = setup_named_route_test
assert_equal "http://named.route.test/people/go/7/hello/joe/5?baz=bar",
controller.send(:multi_url, 7, "hello", 5, :baz => "bar")
end
def test_named_route_url_method_with_ordered_parameters_and_hash_ordered_parameters_override_hash
controller = setup_named_route_test
assert_equal "http://named.route.test/people/go/7/hello/joe/5?baz=bar",
controller.send(:multi_url, 7, "hello", 5, :foo => 666, :baz => "bar")
end
def test_draw_default_route
ActionController::Routing.with_controllers(['users']) do
set.draw do |map|
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册