Created
June 16, 2010 19:11
-
-
Save mileszs/441127 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # I'll forget this again, so I'm saving it somewhere. | |
| # I needed to remove duplicates from a table. | |
| # Here's how I did it. | |
| category_uniques = Category.all.index_by(&:name).values | |
| Category.all.each { |cat| cat.destroy unless category_uniques.include?(cat) } | |
| # Edit: Reduced to two lines, for fun. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment