From 9fd19a36bd93127d977ca46d5aab0350c966614a Mon Sep 17 00:00:00 2001 From: Doug Orleans Date: Mon, 3 Sep 2012 02:32:49 -0400 Subject: [PATCH] Also clear the destroyed flag after synchronizing. --- lib/activerecord-import/synchronize.rb | 3 +++ 1 file changed, 3 insertions(+) diff --git a/lib/activerecord-import/synchronize.rb b/lib/activerecord-import/synchronize.rb index cf97dbe..a5286d7 100644 --- a/lib/activerecord-import/synchronize.rb +++ b/lib/activerecord-import/synchronize.rb @@ -43,7 +43,10 @@ module ActiveRecord # :nodoc: instance.clear_aggregation_cache instance.clear_association_cache instance.instance_variable_set '@attributes', matched_instance.attributes + # Since the instance now accurately reflects the record in + # the database, ensure that instance.persisted? is true. instance.instance_variable_set '@new_record', false + instance.instance_variable_set '@destroyed', false end end end