diff options
author | Andrew White <andyw@pixeltrix.co.uk> | 2012-08-04 11:33:30 +0100 |
---|---|---|
committer | Andrew White <andyw@pixeltrix.co.uk> | 2012-08-04 11:33:30 +0100 |
commit | 067efad8af6e84e45518120a77dfbb0b49c94469 (patch) | |
tree | 2d3043f4348d104ffed67afc2b89d47f98a85379 /actionpack/lib | |
parent | 3d3fa165e40c8cdaaebdab9dd2985d0ca3a36236 (diff) | |
parent | 6be564c7a087773cb0b51c54396cc190e4f5c983 (diff) | |
download | rails-067efad8af6e84e45518120a77dfbb0b49c94469.tar.gz rails-067efad8af6e84e45518120a77dfbb0b49c94469.tar.bz2 rails-067efad8af6e84e45518120a77dfbb0b49c94469.zip |
Merge branch 'polymorphic_url_builds_query_string_with_array'
Diffstat (limited to 'actionpack/lib')
-rw-r--r-- | actionpack/lib/action_dispatch/routing/polymorphic_routes.rb | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/actionpack/lib/action_dispatch/routing/polymorphic_routes.rb b/actionpack/lib/action_dispatch/routing/polymorphic_routes.rb index 3d7b8878b8..93e8418d9c 100644 --- a/actionpack/lib/action_dispatch/routing/polymorphic_routes.rb +++ b/actionpack/lib/action_dispatch/routing/polymorphic_routes.rb @@ -62,6 +62,7 @@ module ActionDispatch # # # calls post_url(post) # polymorphic_url(post) # => "http://example.com/posts/1" + # polymorphic_url([post, :foo => 'bar']) # => "http://example.com/posts/1?foo=bar" # polymorphic_url([blog, post]) # => "http://example.com/blogs/1/posts/1" # polymorphic_url([:admin, blog, post]) # => "http://example.com/admin/blogs/1/posts/1" # polymorphic_url([user, :blog, post]) # => "http://example.com/users/1/blog/posts/1" @@ -92,6 +93,7 @@ module ActionDispatch def polymorphic_url(record_or_hash_or_array, options = {}) if record_or_hash_or_array.kind_of?(Array) record_or_hash_or_array = record_or_hash_or_array.compact + options.reverse_merge!(record_or_hash_or_array.extract_options!) if record_or_hash_or_array.first.is_a?(ActionDispatch::Routing::RoutesProxy) proxy = record_or_hash_or_array.shift end @@ -196,7 +198,8 @@ module ActionDispatch def extract_record(record_or_hash_or_array) case record_or_hash_or_array - when Array; record_or_hash_or_array.last + when Array + record_or_hash_or_array.last when Hash; record_or_hash_or_array[:id] else record_or_hash_or_array end |