#19085 - ActiveRecord::CollectionProxy#delete_all and ActiveRecord::Relation#delete_all do not follow the principle of least surprise

As per a suggestion from Sean Griffin, I am moving the conversation about closed issue #19085 to this mailing list.

I disagree with Sean about whether this is a bug or not, and hope to demonstrate that it is in fact a bug, as per the definition of bug:

A software bug is an error, flaw, failure, or fault in a computer program or system that causes it to produce an incorrect or unexpected result, or to behave in unintended ways.

I think there *is an egregious *flaw in the naming and behavior of two methods in the Rails ActiveRecord API causing confusion and working in very unexpected ways:

Though it seems like the two methods ought to behave identically, and follow the principle of least surprise, they actually behave very surprisingly and differently:

ActiveRecord::CollectionProxy#delete_all and its counterpart ActiveRecord::CollectionProxy#destroy_all take as its argument a dependent parameter, whose default value is nil. This is very different from how ActiveRecord::Relation#delete_all and ActiveRecord::Relation#destroy_all work, which take a set of conditions, such as those that may be passed to ActiveRecord::Base#where.

This doesn’t make any sense, and I had to figure out the reason for the differences by reading the docs, rather than following the obvious assumption that both should work in the same fundamental way, especially given that they are defined on two objects, which are fundamentally similar in their behavior. In a duck typed language, to have two methods on similar receivers that behave in fundamentally different ways and have completely different parameter lists is an obscene and egregious violation of single responsibility principle.

While the answer to this issue may be: “RTFM” - I did, and this seems like an incorrect design decision that may be in need of refactoring, leading to a lot of head scratching.

My proposal, based on the discussion in the original github issue is to: