instance method
to_param
Ruby on Rails 4.2.9
Since v3.0.20Signature
to_param()
Returns a string representing the object’s key suitable for use in URLs, or nil if persisted? is false.
class Person include ActiveModel::Conversion attr_accessor :id def persisted? true end end person = Person.create(id: 1) person.to_param # => "1"
Source
# File activemodel/lib/active_model/conversion.rb, line 71
def to_param
(persisted? && key = to_key) ? key.join('-') : nil
end
Defined in activemodel/lib/active_model/conversion.rb line 71
· View on GitHub
· Improve this page
· Find usages on GitHub
Defined in ActiveModel::Conversion