This project is archived and is in readonly mode.
ActiveRecord `destroy_all` returns empty array instead of destroyed records
-
Neeraj Singh
- State changed from new to open
- Importance changed from to Low
to_a.each {|object| object.destroy }.tap { reset }What if destroy operation fails on an object. In that case even the failed object will show up in the returned collection. I think changing 'each' to 'select' might fix that problem.
If you don't mind can you add test for this edge condition. Thanks.
-
Mislav
That wasn't a behavior of Rails 2.3. Why change it? A user can iterate over the "destroyed" objects collection and check which records are truly
destroyed?and which have failed because ofbefore_destroycallbacks.But you're right: whatever behavior is in place, it should be tested.
-
Mislav
Heads-up to those who might have already pulled: I've just force-pushed something I forgot to my branch for master.