aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAndrey Molchanov <neodelf@gmail.com>2016-09-17 14:21:38 +0300
committerAndrey Molchanov <neodelf@gmail.com>2016-09-17 14:21:38 +0300
commit2003381bbbea8e0436d54111d67e8e118601ae80 (patch)
tree139e0d52852cec6d0e3ea8a6202304c453210782
parent2c5cb411b5755f3cfac7413b1c18e7d65acc208d (diff)
downloadrails-2003381bbbea8e0436d54111d67e8e118601ae80.tar.gz
rails-2003381bbbea8e0436d54111d67e8e118601ae80.tar.bz2
rails-2003381bbbea8e0436d54111d67e8e118601ae80.zip
[ci skip] Fix bad examples in rdoc
-rw-r--r--activemodel/lib/active_model/conversion.rb13
1 files changed, 11 insertions, 2 deletions
diff --git a/activemodel/lib/active_model/conversion.rb b/activemodel/lib/active_model/conversion.rb
index 8bcad6db0f..12687c70d3 100644
--- a/activemodel/lib/active_model/conversion.rb
+++ b/activemodel/lib/active_model/conversion.rb
@@ -46,9 +46,13 @@ module ActiveModel
# 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 @@ module ActiveModel
# 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