mirror of
https://github.com/rails/rails.git
synced 2022-11-09 12:12:34 -05:00
Revert "Don't handle params option in a special way in url_for helper"
This reverts commit e385e4678f
.
While this option was undocumented it exists to make possible to pass
parameters to the route helpers that are reserved like `:domain`.
While `url_for(domain: 'foo.com')` would generate a URL in the `foo.com`
domain `url_for(params: { domain: 'foo.com' })` would generate a URL
with `?domain=foo.com`.
This commit is contained in:
parent
d67863af39
commit
17e4b49292
5 changed files with 14 additions and 5 deletions
|
@ -85,10 +85,6 @@
|
|||
|
||||
*Yoshiyuki Kinjo*
|
||||
|
||||
* Remove undocumented `params` option from `url_for` helper.
|
||||
|
||||
*Ilkka Oksanen*
|
||||
|
||||
* Encode Content-Disposition filenames on `send_data` and `send_file`.
|
||||
Previously, `send_data 'data', filename: "\u{3042}.txt"` sends
|
||||
`"filename=\"\u{3042}.txt\""` as Content-Disposition and it can be
|
||||
|
|
|
@ -820,6 +820,10 @@ module ActionDispatch
|
|||
|
||||
path, params = generate(route_name, path_options, recall)
|
||||
|
||||
if options.key? :params
|
||||
params.merge! options[:params]
|
||||
end
|
||||
|
||||
options[:path] = path
|
||||
options[:script_name] = script_name
|
||||
options[:params] = params
|
||||
|
|
|
@ -133,6 +133,7 @@ module ActionDispatch
|
|||
# <tt>ActionDispatch::Http::URL.tld_length</tt>, which in turn defaults to 1.
|
||||
# * <tt>:port</tt> - Optionally specify the port to connect to.
|
||||
# * <tt>:anchor</tt> - An anchor name to be appended to the path.
|
||||
# * <tt>:params</tt> - The query parameters to be appended to the path.
|
||||
# * <tt>:trailing_slash</tt> - If true, adds a trailing slash, as in "/archive/2009/"
|
||||
# * <tt>:script_name</tt> - Specifies application path relative to domain root. If provided, prepends application path.
|
||||
#
|
||||
|
|
|
@ -193,7 +193,7 @@ class UrlOptionsTest < ActionController::TestCase
|
|||
action: "home",
|
||||
controller: "pages",
|
||||
only_path: true,
|
||||
token: "secret"
|
||||
params: { "token" => "secret" }
|
||||
}
|
||||
|
||||
assert_equal "/home?token=secret", rs.url_for(options)
|
||||
|
|
|
@ -354,6 +354,14 @@ module AbstractController
|
|||
assert_equal({ p2: "Y2" }.to_query, params[1])
|
||||
end
|
||||
|
||||
def test_params_option
|
||||
url = W.new.url_for(only_path: true, controller: "c", action: "a", params: { domain: "foo", id: "1" })
|
||||
params = extract_params(url)
|
||||
assert_equal("/c/a?domain=foo&id=1", url)
|
||||
assert_equal({ domain: "foo" }.to_query, params[0])
|
||||
assert_equal({ id: "1" }.to_query, params[1])
|
||||
end
|
||||
|
||||
def test_hash_parameter
|
||||
url = W.new.url_for(only_path: true, controller: "c", action: "a", query: { name: "Bob", category: "prof" })
|
||||
params = extract_params(url)
|
||||
|
|
Loading…
Reference in a new issue