Skip to content

Commit bc644c5

Browse files
committed
Keep the original implementation to not having to allocate new objects
1 parent f82ecef commit bc644c5

File tree

1 file changed

+15
-2
lines changed

1 file changed

+15
-2
lines changed

actionpack/lib/action_dispatch/routing/polymorphic_routes.rb

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -121,8 +121,21 @@ def polymorphic_url(record_or_hash_or_array, options = {})
121121
# Returns the path component of a URL for the given record. It uses
122122
# <tt>polymorphic_url</tt> with <tt>routing_type: :path</tt>.
123123
def polymorphic_path(record_or_hash_or_array, options = {})
124-
opts = options.reverse_merge(:routing_type => :path)
125-
polymorphic_url(record_or_hash_or_array, opts)
124+
if Hash === record_or_hash_or_array
125+
options = record_or_hash_or_array.merge(options)
126+
record = options.delete :id
127+
return polymorphic_path record, options
128+
end
129+
130+
opts = options.dup
131+
action = opts.delete :action
132+
type = :path
133+
134+
HelperMethodBuilder.polymorphic_method self,
135+
record_or_hash_or_array,
136+
action,
137+
type,
138+
opts
126139
end
127140

128141

0 commit comments

Comments
 (0)