How do I destroy all but the newest n records using Rails\' ActiveRecord?
I can get the newest n records using order and limit but how do I destroy the inverse?
None of these work in Rails 6, but delete_by does.
delete_by
keep_ids = [2345, 345256, 34] Component.delete_by('id NOT IN (?) AND status = "inactive"', keep_ids) }