Skip to content

Instantly share code, notes, and snippets.

Forked from rob-murray/find_dups.rb
Created September 29, 2021 00:20
What would you like to do?
Rails find duplicate records
columns_that_make_record_distinct = [:some_id, :another_name]
distinct_ids ="MIN(id) as id").group(columns_that_make_record_distinct).map(&:id)
duplicate_records = Model.where.not(id: distinct_ids)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment