Delete records with the value in column

I have defined a User model with column name to be unique. I have added index to it now. But now I want to remove all the records which has the same name.

How can I delete all the users with the same name?


This worked.

t = User.all.group_by{|model|}
t.values.each do |duplicates|
  first_one = duplicates.shift
  duplicates.each{|double| double.destroy}