1
0
Fork 0
mirror of https://github.com/rails/rails.git synced 2022-11-09 12:12:34 -05:00

Keep the original implementation to not having to allocate new objects

This commit is contained in:
Rafael Mendonça França 2014-09-25 17:20:52 -03:00
parent f82ecef9ae
commit bc644c54d6

View file

@ -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