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?
Person.destroy_all("last_login < '2004-04-04'")
This will destroy all persons who meet the condition. So all you need is inverted conditions and destroy_all
destroy_all