replace(other_array)
public
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 240
def replace(other_array)
other_array.each { |val| raise_on_type_mismatch!(val) }
original_target = load_target.dup
if owner.new_record?
replace_records(other_array, original_target)
else
replace_common_records_in_memory(other_array, original_target)
if other_array != original_target
transaction { replace_records(other_array, original_target) }
else
other_array
end
end
end