Reputation: 12663
I have a very snowballing program that creates a whole heap of records (from different models).
I want to delete the main record, and make sure all the other records associated have also been deleted.
Is there a way to simply count all records in my DB, regardless of what table? Then I can create everything, trigger the main delete, then check if there's anything left in the DB.
Upvotes: 1
Views: 1026
Reputation: 27779
Rails.application.eager_load!
ActiveRecord::Base.subclasses.sum(&:count)
Upvotes: 4