instance method
to_param
Ruby on Rails 4.1.16
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 < ActiveRecord::Base end person = Person.create person.to_param # => "1"
Source
# File activemodel/lib/active_model/conversion.rb, line 64
def to_param
(persisted? && key = to_key) ? key.join('-') : nil
end
Defined in activemodel/lib/active_model/conversion.rb line 64
· View on GitHub
· Improve this page
· Find usages on GitHub
Defined in ActiveModel::Conversion