From bc644c54d635e2f608c554bdc055e4be1ba47ba5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rafael=20Mendon=C3=A7a=20Fran=C3=A7a?= Date: Thu, 25 Sep 2014 17:20:52 -0300 Subject: Keep the original implementation to not having to allocate new objects --- .../lib/action_dispatch/routing/polymorphic_routes.rb | 17 +++++++++++++++-- 1 file 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 # polymorphic_url with routing_type: :path. 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 -- cgit v1.2.3