From c5807728d52c98b76e9badd95093471044b98d07 Mon Sep 17 00:00:00 2001 From: Andrew White Date: Sat, 4 Aug 2012 19:01:37 +0100 Subject: Revert "polymorphic_url with an array generates a query string" Passing options as the last value in an array doesn't work with form_for. This reverts commit 61c8a4d926343903593a27080216af7e4ed81268. --- .../lib/action_dispatch/routing/polymorphic_routes.rb | 5 +---- actionpack/test/activerecord/polymorphic_routes_test.rb | 14 -------------- 2 files changed, 1 insertion(+), 18 deletions(-) diff --git a/actionpack/lib/action_dispatch/routing/polymorphic_routes.rb b/actionpack/lib/action_dispatch/routing/polymorphic_routes.rb index 7bdd9244d1..3d7b8878b8 100644 --- a/actionpack/lib/action_dispatch/routing/polymorphic_routes.rb +++ b/actionpack/lib/action_dispatch/routing/polymorphic_routes.rb @@ -62,7 +62,6 @@ 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" @@ -165,7 +164,6 @@ module ActionDispatch def build_named_route_call(records, inflection, options = {}) if records.is_a?(Array) - query_string = records.pop if records.last.is_a?(Hash) record = records.pop route = records.map do |parent| if parent.is_a?(Symbol) || parent.is_a?(String) @@ -198,8 +196,7 @@ module ActionDispatch def extract_record(record_or_hash_or_array) case record_or_hash_or_array - when Array - record_or_hash_or_array.last.is_a?(Hash) ? record_or_hash_or_array[-2] : 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 diff --git a/actionpack/test/activerecord/polymorphic_routes_test.rb b/actionpack/test/activerecord/polymorphic_routes_test.rb index 3e6dce9590..afb714484b 100644 --- a/actionpack/test/activerecord/polymorphic_routes_test.rb +++ b/actionpack/test/activerecord/polymorphic_routes_test.rb @@ -309,20 +309,6 @@ class PolymorphicRoutesTest < ActionController::TestCase end end - def test_with_array_containing_simple_hash - with_test_routes do - @project.save - assert_equal "http://example.com/projects/#{@project.id}?foo=bar", polymorphic_url([@project, :foo => 'bar' ]) - end - end - - def test_with_array_containing_complex_hash - with_test_routes do - @project.save - assert_equal "http://example.com/projects/#{@project.id}?foo=bar&nested%5Bfoo%5D=bar", polymorphic_url([@project, :nested => { :foo => 'bar' }, :foo => 'bar']) - end - end - def test_with_array_containing_single_name with_test_routes do @project.save -- cgit v1.2.3