I wonder what is the best way to delete all the records of the association on a specified condition.
For example, you have User model that has many Post(s). How would keep all the recent User’s Posts and delete all the last Posts when a Users have more than 25 ?
There is a solution like that:
old_posts = 
users = includes(:post)
users.each do |user|
old_posts =+ user.posts.offset(25) unless user.posts.empty?
Any other ideas ? Thank you.