Replace this collection with other_array This will perform a diff
and delete/add only records that have changed.
# File activerecord/lib/active_record/associations/collection_association.rb, line 294
def replace(other_array)
other_array.each { |val| raise_on_type_mismatch(val) }
original_target = load_target.dup
transaction do
delete(target - other_array)
unless concat(other_array - target)
@target = original_target
raise RecordNotSaved, "Failed to replace #{reflection.name} because one or more of the " "new records could not be saved."
end
end
end