提交 00dad034 编写于 作者: S Sean Griffin

Define attribute methods before attempting to populate records

`initialize_internals_callback` will attempt to assign attributes from
the current scope, which will fail if something defined the method
and calls super (meaning it won't hit `method_missing`).

Fixes #18339
上级 3d0c7186
......@@ -276,11 +276,11 @@ def table_metadata # :nodoc:
# User.new(first_name: 'Jamie')
def initialize(attributes = nil, options = {})
@attributes = self.class._default_attributes.dup
self.class.define_attribute_methods
init_internals
initialize_internals_callback
self.class.define_attribute_methods
# +options+ argument is only needed to make protected_attributes gem easier to hook.
# Remove it when we drop support to this gem.
init_attributes(attributes, options) if attributes
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册