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:
parent
f82ecef9ae
commit
bc644c54d6
1 changed files with 15 additions and 2 deletions
|
@ -121,8 +121,21 @@ module ActionDispatch
|
||||||
# Returns the path component of a URL for the given record. It uses
|
# Returns the path component of a URL for the given record. It uses
|
||||||
# <tt>polymorphic_url</tt> with <tt>routing_type: :path</tt>.
|
# <tt>polymorphic_url</tt> with <tt>routing_type: :path</tt>.
|
||||||
def polymorphic_path(record_or_hash_or_array, options = {})
|
def polymorphic_path(record_or_hash_or_array, options = {})
|
||||||
opts = options.reverse_merge(:routing_type => :path)
|
if Hash === record_or_hash_or_array
|
||||||
polymorphic_url(record_or_hash_or_array, opts)
|
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
|
end
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue