mirror of
https://github.com/rails/rails.git
synced 2022-11-09 12:12:34 -05:00
Don't assign default attributes until after loading schema
If the call to `.define_attribute_methods` actually ends up loading the schema (*very* hard to do, as it requires the object being created without `allocate` having been called, but it can be done by manually calling `initialize` from inside `marshal_load` if you're crazy), the value of `_default_attributes` will change from that call.
This commit is contained in:
parent
a8482138a4
commit
98faa2a6a1
1 changed files with 1 additions and 1 deletions
|
@ -330,8 +330,8 @@ module ActiveRecord
|
|||
# # Instantiates a single new object
|
||||
# User.new(first_name: 'Jamie')
|
||||
def initialize(attributes = nil)
|
||||
@attributes = self.class._default_attributes.deep_dup
|
||||
self.class.define_attribute_methods
|
||||
@attributes = self.class._default_attributes.deep_dup
|
||||
|
||||
init_internals
|
||||
initialize_internals_callback
|
||||
|
|
Loading…
Reference in a new issue