Skip to content

Instantly share code, notes, and snippets.

View karandocs's full-sized avatar
🎮

Karan karandocs

🎮
View GitHub Profile
@rob-murray
rob-murray / find_dups.rb
Created October 27, 2015 09:59
Rails find duplicate records
columns_that_make_record_distinct = [:some_id, :another_name]
distinct_ids = Model.select("MIN(id) as id").group(columns_that_make_record_distinct).map(&:id)
duplicate_records = Model.where.not(id: distinct_ids)