提交 01421d5b 编写于 作者: S Sean Griffin

Clarify the role of `ActiveRecord::Core.encode_with`

Fixes #19568
上级 445c12f7
......@@ -305,15 +305,19 @@ def initialize(attributes = nil)
_run_initialize_callbacks
end
# Initialize an empty model object from +coder+. +coder+ must contain
# the attributes necessary for initializing an empty model object. For
# example:
# Initialize an empty model object from +coder+. +coder+ should be
# the result of previously encoding an Active Record model, using
# `encode_with`
#
# class Post < ActiveRecord::Base
# end
#
# old_post = Post.new(title: "hello world")
# coder = {}
# old_post.encode_with(coder)
#
# post = Post.allocate
# post.init_with('attributes' => { 'title' => 'hello world' })
# post.init_with(coder)
# post.title # => 'hello world'
def init_with(coder)
coder = LegacyYamlAdapter.convert(self.class, coder)
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册