class ActiveRecord::Associations::CollectionAssociation

def insert_record(record, validate = true, raise = false, &block)

Do the relevant stuff to insert the given record into the association collection.
def insert_record(record, validate = true, raise = false, &block)
  if raise
    record.save!(validate: validate, &block)
  else
    record.save(validate: validate, &block)
  end
end