提交 7b24cf03 编写于 作者: N Neeraj Singh

emphasize that callbacks are called in destroy_all

Cleaned up rdoc a bit emphasizing that callbacks are called. Also
removed the stress on the fact that records are always removed.

If callbacks return false then records will not be deleted.
上级 d790b50d
......@@ -237,11 +237,11 @@ def delete(*records)
end
end
# Destroy +records+ and remove them from this association calling
# +before_remove+ and +after_remove+ callbacks.
# Deletes the +records+ and removes them from this association calling
# +before_remove+ , +after_remove+ , +before_destroy+ and +after_destroy+ callbacks.
#
# Note that this method will _always_ remove records from the database
# ignoring the +:dependent+ option.
# Note that this method removes records from the database ignoring the
# +:dependent+ option.
def destroy(*records)
records = find(records) if records.any? { |record| record.kind_of?(Fixnum) || record.kind_of?(String) }
delete_or_destroy(records, :destroy)
......
......@@ -422,9 +422,9 @@ def delete_all
@association.delete_all
end
# Deletes the records of the collection directly from the database.
# This will _always_ remove the records ignoring the +:dependent+
# option.
# Deletes the records of the collection directly from the database
# ignoring the +:dependent+ option. It invokes +before_remove+,
# +after_remove+ , +before_destroy+ and +after_destroy+ callbacks.
#
# class Person < ActiveRecord::Base
# has_many :pets
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册