aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/lib/active_record/core.rb
diff options
context:
space:
mode:
authorSean Griffin <sean@seantheprogrammer.com>2016-11-03 13:55:46 -0400
committerSean Griffin <sean@seantheprogrammer.com>2016-11-03 13:57:13 -0400
commit98faa2a6a12e849119b60c72b08a25b03d3c867c (patch)
treefe7064c5e557097e2f046c633b931ca6c2e72c42 /activerecord/lib/active_record/core.rb
parenta8482138a4fb69e91a7e7c7184b296800d949d6e (diff)
downloadrails-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.
Diffstat (limited to 'activerecord/lib/active_record/core.rb')
-rw-r--r--activerecord/lib/active_record/core.rb2
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