Removing "duplicate objects"

Posted by keruilin on Stack Overflow See other posts from Stack Overflow or by keruilin
Published on 2010-05-07T16:14:40Z Indexed on 2010/05/07 16:18 UTC
Read the original article Hit count: 122

Let's say I have an array of objects from the same class, with two attributes of concern here: name and created_at.

How do I find objects with the same name (considered dups) in the array, and then delete the duplicate record in the database. The object with the most-recent created_at date, however, is the one that must be deleted.

© Stack Overflow or respective owner

Related posts about ruby-on-rails

Related posts about ruby