class ActiveRecord::Associations::CollectionProxy
def replace(other_array)
person.pets.replace(["doo", "ggie", "gaga"])
an ActiveRecord::AssociationTypeMismatch error:
If the supplied array has an incorrect association type, it raises
# => [#
person.pets
person.pets.replace(other_pets)
other_pets = [Pet.new(name: 'Puff', group: 'celebrities')]
# => [#
person.pets
end
has_many :pets
class Person < ActiveRecord::Base
and delete/add only records that have changed.
Replaces this collection with +other_array+. This will perform a diff
def replace(other_array) @association.replace(other_array) end