aboutsummaryrefslogtreecommitdiffstats
path: root/actionpack/lib/action_dispatch/routing
diff options
context:
space:
mode:
authorRafael Mendonça França <rafaelmfranca@gmail.com>2014-09-25 17:20:52 -0300
committerRafael Mendonça França <rafaelmfranca@gmail.com>2014-09-25 17:20:52 -0300
commitbc644c54d635e2f608c554bdc055e4be1ba47ba5 (patch)
tree17791a4791eddf95a7702abe91a7fd4f6c7c4f1b /actionpack/lib/action_dispatch/routing
parentf82ecef9aef1798fa874c5104fef9d0dd072e757 (diff)
downloadrails-bc644c54d635e2f608c554bdc055e4be1ba47ba5.tar.gz
rails-bc644c54d635e2f608c554bdc055e4be1ba47ba5.tar.bz2
rails-bc644c54d635e2f608c554bdc055e4be1ba47ba5.zip
Keep the original implementation to not having to allocate new objects
Diffstat (limited to 'actionpack/lib/action_dispatch/routing')
-rw-r--r--actionpack/lib/action_dispatch/routing/polymorphic_routes.rb17
1 files changed, 15 insertions, 2 deletions
diff --git a/actionpack/lib/action_dispatch/routing/polymorphic_routes.rb b/actionpack/lib/action_dispatch/routing/polymorphic_routes.rb
index 1fa438f2eb..0847842fa2 100644
--- a/actionpack/lib/action_dispatch/routing/polymorphic_routes.rb
+++ b/actionpack/lib/action_dispatch/routing/polymorphic_routes.rb
@@ -121,8 +121,21 @@ module ActionDispatch
# 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 = {})
- opts = options.reverse_merge(:routing_type => :path)
- polymorphic_url(record_or_hash_or_array, opts)
+ 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
end