提交 d71eaf3e 编写于 作者: N Neeraj Singh

Show warning message if delete_all is firing callbacks

`post.comments.delete_all` will fire callbacks if :dependent option is
:destroy . It will be fixed in Rails 4.1 . In the meantime display
a warning . Look at #9567 for details .
上级 464cd9dc
......@@ -204,6 +204,15 @@ def delete(*records)
dependent = options[:dependent]
if records.first == :all
if dependent && dependent == :destroy
message = 'In Rails 4.1 delete_all on associations would not fire callbacks. ' \
'It means if the :dependent option is :destroy then the associated ' \
'records would be deleted without loading and invoking callbacks.'
ActiveRecord::Base.logger ? ActiveRecord::Base.logger.warn(message) : $stderr.puts(message)
end
if loaded? || dependent == :destroy
delete_or_destroy(load_target, dependent)
else
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册