提交 2003381b 编写于 作者: A Andrey Molchanov

[ci skip] Fix bad examples in rdoc

上级 2c5cb411
......@@ -46,9 +46,13 @@ def to_model
# class Person
# include ActiveModel::Conversion
# attr_accessor :id
#
# def initialize(id)
# @id = id
# end
# end
#
# person = Person.create(id: 1)
# person = Person.new(1)
# person.to_key # => [1]
def to_key
key = respond_to?(:id) && id
......@@ -61,12 +65,17 @@ def to_key
# class Person
# include ActiveModel::Conversion
# attr_accessor :id
#
# def initialize(id)
# @id = id
# end
#
# def persisted?
# true
# end
# end
#
# person = Person.create(id: 1)
# person = Person.new(1)
# person.to_param # => "1"
def to_param
(persisted? && key = to_key) ? key.join("-") : nil
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册