Skip to content

Instantly share code, notes, and snippets.

@mtunjic
Created August 4, 2011 07:57
Show Gist options
  • Select an option

  • Save mtunjic/1124682 to your computer and use it in GitHub Desktop.

Select an option

Save mtunjic/1124682 to your computer and use it in GitHub Desktop.
Remove Duplicate Active Record Objects
require 'set'
class Array
def uniq_by
seen = Set.new
select{ |x| seen.add?( yield( x ) ) }
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment