diff options
author | Gert Goet <gert@thinkcreate.nl> | 2014-09-25 17:50:16 +0200 |
---|---|---|
committer | Gert Goet <gert@thinkcreate.nl> | 2014-09-25 17:50:16 +0200 |
commit | 2d08fd250638a39fbc8509b4e1c3f87a5f9e36c6 (patch) | |
tree | 86235eaae656896745748ec3570ce8e27bde0aaa | |
parent | f620299b2784f7ce5f01a4e123525d04f97be4dd (diff) | |
download | rails-2d08fd250638a39fbc8509b4e1c3f87a5f9e36c6.tar.gz rails-2d08fd250638a39fbc8509b4e1c3f87a5f9e36c6.tar.bz2 rails-2d08fd250638a39fbc8509b4e1c3f87a5f9e36c6.zip |
Remove internal options from query string of paths
Fixes #17057
-rw-r--r-- | actionpack/CHANGELOG.md | 7 | ||||
-rw-r--r-- | actionpack/lib/action_dispatch/routing/polymorphic_routes.rb | 21 | ||||
-rw-r--r-- | actionview/test/activerecord/polymorphic_routes_test.rb | 9 |
3 files changed, 19 insertions, 18 deletions
diff --git a/actionpack/CHANGELOG.md b/actionpack/CHANGELOG.md index de9722c392..4a79b2efec 100644 --- a/actionpack/CHANGELOG.md +++ b/actionpack/CHANGELOG.md @@ -1,3 +1,10 @@ +* Fix bug where `routing_type=path` would end up in query string of paths + generated by `edit_` and `new_polymorphic_path` + + Fixes #17057. + + *Gert Goet* + * Deprecate implicit Array conversion for Response objects. It was added (using `#to_ary`) so we could conveniently use implicit splatting: diff --git a/actionpack/lib/action_dispatch/routing/polymorphic_routes.rb b/actionpack/lib/action_dispatch/routing/polymorphic_routes.rb index f15868d37e..1fa438f2eb 100644 --- a/actionpack/lib/action_dispatch/routing/polymorphic_routes.rb +++ b/actionpack/lib/action_dispatch/routing/polymorphic_routes.rb @@ -116,27 +116,13 @@ module ActionDispatch action, type, opts - end # Returns the path component of a URL for the given record. It uses # <tt>polymorphic_url</tt> with <tt>routing_type: :path</tt>. def polymorphic_path(record_or_hash_or_array, options = {}) - if Hash === record_or_hash_or_array - options = record_or_hash_or_array.merge(options) - record = options.delete :id - return polymorphic_path record, options - end - - opts = options.dup - action = opts.delete :action - type = :path - - HelperMethodBuilder.polymorphic_method self, - record_or_hash_or_array, - action, - type, - opts + opts = options.reverse_merge(:routing_type => :path) + polymorphic_url(record_or_hash_or_array, opts) end @@ -159,8 +145,7 @@ module ActionDispatch end def polymorphic_path_for_action(action, record_or_hash, options) - options = options.merge(:action => action, :routing_type => :path) - polymorphic_path(record_or_hash, options) + polymorphic_path(record_or_hash, options.merge(:action => action)) end class HelperMethodBuilder # :nodoc: diff --git a/actionview/test/activerecord/polymorphic_routes_test.rb b/actionview/test/activerecord/polymorphic_routes_test.rb index 4e94304796..5842b775bb 100644 --- a/actionview/test/activerecord/polymorphic_routes_test.rb +++ b/actionview/test/activerecord/polymorphic_routes_test.rb @@ -282,6 +282,15 @@ class PolymorphicRoutesTest < ActionController::TestCase end end + def test_regression_path_helper_prefixed_with_new_and_edit + with_test_routes do + assert_equal "/projects/new", new_polymorphic_path(@project) + + @project.save + assert_equal "/projects/#{@project.id}/edit", edit_polymorphic_path(@project) + end + end + def test_url_helper_prefixed_with_edit with_test_routes do @project.save |