Skip to content

Instantly share code, notes, and snippets.

@0xGGGGG
Created November 10, 2013 11:53
Show Gist options
  • Save 0xGGGGG/7397304 to your computer and use it in GitHub Desktop.
Save 0xGGGGG/7397304 to your computer and use it in GitHub Desktop.
arel duplicates
User
.where(
phone: User
.select('phone, count(phone)')
.group('phone')
.having('count(phone) > 1')
.select{|u| u.phone.present?}
.map(&:phone) )
.select([:id, :phone, :email, :fullname])
.includes(:items)
.order(:phone)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment