instance method
polymorphic_path
Ruby on Rails 7.2.3
Since v3.0.20Signature
polymorphic_path(record_or_hash_or_array, options = {})
Returns the path component of a URL for the given record.
Parameters
-
record_or_hash_or_arrayreq -
optionsopt = {}
Source
# File actionpack/lib/action_dispatch/routing/polymorphic_routes.rb, line 133
def polymorphic_path(record_or_hash_or_array, options = {})
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
if mapping = polymorphic_mapping(record_or_hash_or_array)
return mapping.call(self, [record_or_hash_or_array, options], true)
end
opts = options.dup
action = opts.delete :action
type = :path
HelperMethodBuilder.polymorphic_method self,
record_or_hash_or_array,
action,
type,
opts
end
Defined in actionpack/lib/action_dispatch/routing/polymorphic_routes.rb line 133
· View on GitHub
· Improve this page
· Find usages on GitHub
Defined in ActionDispatch::Routing::PolymorphicRoutes