diff options
author | Sean Griffin <sean@seantheprogrammer.com> | 2016-11-03 13:55:46 -0400 |
---|---|---|
committer | Sean Griffin <sean@seantheprogrammer.com> | 2016-11-03 13:57:13 -0400 |
commit | 98faa2a6a12e849119b60c72b08a25b03d3c867c (patch) | |
tree | fe7064c5e557097e2f046c633b931ca6c2e72c42 | |
parent | a8482138a4fb69e91a7e7c7184b296800d949d6e (diff) | |
download | rails-98faa2a6a12e849119b60c72b08a25b03d3c867c.tar.gz rails-98faa2a6a12e849119b60c72b08a25b03d3c867c.tar.bz2 rails-98faa2a6a12e849119b60c72b08a25b03d3c867c.zip |
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.
-rw-r--r-- | activerecord/lib/active_record/core.rb | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/activerecord/lib/active_record/core.rb b/activerecord/lib/active_record/core.rb index 0a9c06ba59..1fbe374ade 100644 --- a/activerecord/lib/active_record/core.rb +++ b/activerecord/lib/active_record/core.rb @@ -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 |