Skip to content

Instantly share code, notes, and snippets.

@Sillson
Created August 13, 2015 17:07
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Sillson/1660df5945d87117e2ed to your computer and use it in GitHub Desktop.
Save Sillson/1660df5945d87117e2ed to your computer and use it in GitHub Desktop.
Find dupes
# How to find duplicate website objects in a CMS!
#map an array of all websites 'owner_id'
loc_ids = Website.all.map {|web| web.owner_id}
#returns the duplicates
loc_ids.select{ |id| loc_ids.count(id) > 1}.uniq
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment