After speaking with Sean Griffin a bunch, I’ve decided to follow his lead and move the conversation here.
I am happy to write and submit a PR for this issue, but wanted to have a discussion before doing that. Unfortunately, Sean had shut me down - and I think that was absolutely ridiculous, but beside the point. So, here’s the issue, one more time:
Though it seems like the two methods above ought to behave identically, and follow the principle of least surprise, they actually behave very surprisingly and differently:
ActiveRecord::CollectionProxy#delete_all
and its counterpartActiveRecord::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
andActiveRecord::Relation#destroy_all
work, which take a set of conditions, such as those that may be passed to ActiveRecord::Base#where
.
This doesn’t seem to make any sense, and caused me to figure out the answer by reading the docs, rather than following the obvious assumption that both should work in the same fundamental way.
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.