activerecord/lib/active_record/associations/collection_association.rb
# Removes all records from the association without calling callbacks
# on the associated records. It honors the +:dependent+ option. However
# if the +:dependent+ value is +:destroy+ then in that case the +:delete_all+
# deletion strategy for the association is applied.
#
# You can force a particular deletion strategy by passing a parameter.
#
# Example:
#
# @author.books.delete_all(:nullify)
# @author.books.delete_all(:delete_all)
#
# See delete for more info.
Removes all records from the association without calling callbacks
on the associated records. It honors the +:dependent+ option.

You can force a particular deletion strategy by passing a parameter.


Removes all records from the association without calling callbacks on the associated records . It honors the + : dependent + option . You can force a particular deletion strategy by passing a parameter .
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
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
Removes all records from the association without calling callbacks
on the associated records.
Removes all records from the association without calling callbacks on the associated records .
dependent
<not_specific>
author.books.delete_all(:nullify)
None
author.books.delete_all(:delete_all)
See delete for more info.
See delete for more info .