aboutsummaryrefslogtreecommitdiffstats
path: root/actionpack
diff options
context:
space:
mode:
authorAndrew White <andyw@pixeltrix.co.uk>2012-08-04 18:58:33 +0100
committerAndrew White <andyw@pixeltrix.co.uk>2012-08-04 19:02:57 +0100
commit4059423809c38d2365701ce055e97420228a87db (patch)
tree22999f72508d76c654d8720ec1c9d98756d87aa1 /actionpack
parent96290d4faf5f9463bfbac08f10af5ac4753c715a (diff)
downloadrails-4059423809c38d2365701ce055e97420228a87db.tar.gz
rails-4059423809c38d2365701ce055e97420228a87db.tar.bz2
rails-4059423809c38d2365701ce055e97420228a87db.zip
Revert "Refactor passing url options via array for polymorphic_url"
Passing options as the last value in an array doesn't work with form_for. This reverts commit 6be564c7a087773cb0b51c54396cc190e4f5c983.
Diffstat (limited to 'actionpack')
-rw-r--r--actionpack/CHANGELOG.md2
-rw-r--r--actionpack/lib/action_dispatch/routing/polymorphic_routes.rb4
-rw-r--r--actionpack/test/activerecord/polymorphic_routes_test.rb7
3 files changed, 2 insertions, 11 deletions
diff --git a/actionpack/CHANGELOG.md b/actionpack/CHANGELOG.md
index 861e086372..68cce142a2 100644
--- a/actionpack/CHANGELOG.md
+++ b/actionpack/CHANGELOG.md
@@ -1,7 +1,5 @@
## Rails 4.0.0 (unreleased) ##
-* Add the ability to pass options as part of the array notation for `polymorphic_url` *Romain Tribes*
-
* Fixed issue with where Digest authentication would not work behind a proxy. *Arthur Smith*
* Added ActionController::Live. Mix it in to your controller and you can
diff --git a/actionpack/lib/action_dispatch/routing/polymorphic_routes.rb b/actionpack/lib/action_dispatch/routing/polymorphic_routes.rb
index 93e8418d9c..7bdd9244d1 100644
--- a/actionpack/lib/action_dispatch/routing/polymorphic_routes.rb
+++ b/actionpack/lib/action_dispatch/routing/polymorphic_routes.rb
@@ -93,7 +93,6 @@ 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
@@ -166,6 +165,7 @@ 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)
@@ -199,7 +199,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
+ record_or_hash_or_array.last.is_a?(Hash) ? record_or_hash_or_array[-2] : 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 9454a6d726..3e6dce9590 100644
--- a/actionpack/test/activerecord/polymorphic_routes_test.rb
+++ b/actionpack/test/activerecord/polymorphic_routes_test.rb
@@ -323,13 +323,6 @@ class PolymorphicRoutesTest < ActionController::TestCase
end
end
- def test_with_array_containing_simple_hash_options_take_precedence
- with_test_routes do
- @project.save
- assert_equal "http://example.com/projects/#{@project.id}?foo=baz", polymorphic_url([@project, :foo => 'bar' ], :foo => 'baz')
- end
- end
-
def test_with_array_containing_single_name
with_test_routes do
@project.save