From 3529bbd8cab56db5fea527cdd2f21e7d2552d62e Mon Sep 17 00:00:00 2001 From: Sean Griffin Date: Sun, 22 Jun 2014 14:34:31 -0600 Subject: `reload` should fully reload attributes `reload` is meant to put a record in the same state it would be if you were to do `Post.find(post.id)`. This means we should fully replace the attributes hash. --- activerecord/lib/active_record/attribute_set.rb | 4 ---- activerecord/lib/active_record/persistence.rb | 2 +- 2 files changed, 1 insertion(+), 5 deletions(-) (limited to 'activerecord/lib/active_record') diff --git a/activerecord/lib/active_record/attribute_set.rb b/activerecord/lib/active_record/attribute_set.rb index 8f6b73eac2..5e5f7ca1b5 100644 --- a/activerecord/lib/active_record/attribute_set.rb +++ b/activerecord/lib/active_record/attribute_set.rb @@ -6,10 +6,6 @@ module ActiveRecord @attributes = attributes end - def update(other) - attributes.update(other.attributes) - end - def to_hash attributes.each_with_object({}) { |(k, v), h| h[k] = v.value } end diff --git a/activerecord/lib/active_record/persistence.rb b/activerecord/lib/active_record/persistence.rb index 6707f12489..86cc928644 100644 --- a/activerecord/lib/active_record/persistence.rb +++ b/activerecord/lib/active_record/persistence.rb @@ -395,7 +395,7 @@ module ActiveRecord self.class.unscoped { self.class.find(id) } end - @attributes.update(fresh_object.instance_variable_get('@attributes')) + @attributes = fresh_object.instance_variable_get('@attributes') @column_types = self.class.column_types self -- cgit v1.2.3