File tree Expand file tree Collapse file tree 3 files changed +16
-2
lines changed Expand file tree Collapse file tree 3 files changed +16
-2
lines changed Original file line number Diff line number Diff line change 1
1
## Rails 4.0.0 (unreleased) ##
2
2
3
+ * Fix error when using a non-hash query argument named "params" in ` url_for ` .
4
+
5
+ Before:
6
+
7
+ url_for(params: "") # => undefined method `reject!' for "":String
8
+
9
+ After:
10
+
11
+ url_for(params: "") # => http://www.example.com?params=
12
+
13
+ * tumayun + Carlos Antonio da Silva*
14
+
3
15
* Render every partial with a new ` ActionView::PartialRenderer ` . This resolves
4
16
issues when rendering nested partials.
5
17
Fix #8197
Original file line number Diff line number Diff line change @@ -28,7 +28,7 @@ def url_for(options = {})
28
28
path = options . delete ( :script_name ) . to_s . chomp ( "/" )
29
29
path << options . delete ( :path ) . to_s
30
30
31
- params = options [ :params ] || { }
31
+ params = options [ :params ] . is_a? ( Hash ) ? options [ :params ] : options . slice ( :params )
32
32
params . reject! { |_ , v | v . to_param . nil? }
33
33
34
34
result = build_host_url ( options )
Original file line number Diff line number Diff line change 3
3
class RequestTest < ActiveSupport ::TestCase
4
4
5
5
def url_for ( options = { } )
6
- options . reverse_merge! ( :host => 'www.example.com' )
6
+ options = { host : 'www.example.com' } . merge! ( options )
7
7
ActionDispatch ::Http ::URL . url_for ( options )
8
8
end
9
9
@@ -25,6 +25,8 @@ def url_for(options = {})
25
25
assert_equal 'http://www.example.com/' , url_for ( :trailing_slash => true )
26
26
assert_equal 'http://dhh:[email protected] ' , url_for ( :user => 'dhh' , :password => 'supersecret' )
27
27
assert_equal 'http://www.example.com?search=books' , url_for ( :params => { :search => 'books' } )
28
+ assert_equal 'http://www.example.com?params=' , url_for ( :params => '' )
29
+ assert_equal 'http://www.example.com?params=1' , url_for ( :params => 1 )
28
30
end
29
31
30
32
test "remote ip" do
You can’t perform that action at this time.
0 commit comments