class ActiveRecord::Associations::CollectionAssociation
def delete_all(dependent = nil)
@author.books.delete_all(:delete_all)
@author.books.delete_all(:nullify)
Example:
You can force a particular deletion strategy by passing a parameter.
deletion strategy for the association is applied.
if the +:dependent+ value is +:destroy+ then in that case the +:delete_all+
on the associated records. It honors the +:dependent+ option. However
Removes all records from the association without calling callbacks
def delete_all(dependent = nil) if dependent && ![:nullify, :delete_all].include?(dependent) raise ArgumentError, "Valid values are :nullify or :delete_all" end dependent = if dependent dependent elsif options[:dependent] == :destroy :delete_all else options[:dependent] end delete_or_nullify_all_records(dependent).tap do reset loaded! end end