To-the-dot duplicated email records can be identified directly in your SQL statement or in your ruby app code.
Here's a simple query to return all normalized email and the number of users associated with each normalized email:
User.group("replace(email,'.','')").count
which is translated to the following SQL:
SELECT COUNT(*) AS count_all, replace(email,'.','') AS replace_email FROM "users" GROUP BY replace(email,'.','')
and returns something like the following hash:
{"x@gmailcom"=>1, "da@gmailcom"=>2}
Indicating there are 2 users with normalized email equals to da@gmailcom
.
Alternitevly you can use group_by in ruby code:
User.all.group_by{ |u| u.email.gsub('.','') }