Source context:
has_many_association.rb line 89:
def clear
@association_class.update_all("#{@association_class_primary_key_name} = NULL", "#{@association_class_primary_key_name}
= #{@owner.quoted_id}")
@target = []
self
end
Discussion:
AWDwR Book p.228 states:
orders.delete(order1, ...)
Deletes one or more order objects from the list of orders associated
with this customer. This does not delete the order objects from the
databaseòÃÂâÂÂit simply sets their customer_id foreign keys to null, break-
ing their association.
orders.clear
Disassociates all orders from this customer. Like delete( ), this breaks
the association but deletes the orders from the database only if they
were marked as :dependent.
API docs:
collection.delete(object, òÃÂæ) - removes one or more objects from the
collection by setting their foreign keys to NULL. This will also destroy the
objects if theyòÃÂâ¢re declared as belongs_to and dependent on this model.
collection.clear - removes every object from the collection. This does not
destroy the objects.
---
Explanations:
Neither book nor api docs don't respond to real implementation of clear() method.
So there's no correct specification for behavior of clear() method.
I consider this to be a bug.