aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/lib/active_record/core.rb
diff options
context:
space:
mode:
Diffstat (limited to 'activerecord/lib/active_record/core.rb')
-rw-r--r--activerecord/lib/active_record/core.rb8
1 files changed, 2 insertions, 6 deletions
diff --git a/activerecord/lib/active_record/core.rb b/activerecord/lib/active_record/core.rb
index 224112b559..b11c4f804f 100644
--- a/activerecord/lib/active_record/core.rb
+++ b/activerecord/lib/active_record/core.rb
@@ -315,9 +315,8 @@ module ActiveRecord
##
def initialize_dup(other) # :nodoc:
- pk = self.class.primary_key
@attributes = @attributes.dup
- @attributes.write_from_database(pk, nil)
+ @attributes.reset(self.class.primary_key)
run_callbacks(:initialize) unless _initialize_callbacks.empty?
@@ -515,10 +514,7 @@ module ActiveRecord
end
def init_internals
- pk = self.class.primary_key
- if pk && !@attributes.include?(pk)
- @attributes.write_from_database(pk, nil)
- end
+ @attributes.ensure_initialized(self.class.primary_key)
@aggregation_cache = {}
@association_cache = {}