module ActiveModel::Conversion

def to_key

person.to_key # => [1]
person = Person.new(1)

end
end
@id = id
def initialize(id)

attr_accessor :id
include ActiveModel::Conversion
class Person

the object is persisted. Returns +nil+ if there are no key attributes.
Returns an Array of all key attributes if any of the attributes is set, whether or not
def to_key
  key = respond_to?(:id) && id
  key ? Array(key) : nil
end