Skip to content

Commit b973e00

Browse files
committed
do not override special param in url_for options
1 parent a049217 commit b973e00

File tree

2 files changed

+9
-0
lines changed

2 files changed

+9
-0
lines changed

actionpack/lib/action_dispatch/routing/route_set.rb

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -824,6 +824,8 @@ def url_for(options, route_name = nil, url_strategy = UNKNOWN, method_name = nil
824824

825825
if options[:params].is_a?(Hash)
826826
params.merge! options[:params]
827+
elsif options.key? :params
828+
params[:params] = options[:params]
827829
end
828830

829831
options[:path] = path

actionpack/test/controller/url_for_test.rb

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -362,6 +362,13 @@ def test_params_option
362362
assert_equal({ id: "1" }.to_query, params[1])
363363
end
364364

365+
def test_non_hash_params_option
366+
url = W.new.url_for(only_path: true, controller: "c", action: "a", params: "p")
367+
params = extract_params(url)
368+
assert_equal("/c/a?params=p", url)
369+
assert_equal({ params: "p" }.to_query, params[0])
370+
end
371+
365372
def test_hash_parameter
366373
url = W.new.url_for(only_path: true, controller: "c", action: "a", query: { name: "Bob", category: "prof" })
367374
params = extract_params(url)

0 commit comments

Comments
 (0)