Hi somehow, don’t ask why I am currently in the situation where:
I as admin have three e-mails addresses listed:
Primary: the correct one
Secondary: the same one but unconfirmed
Third one: truly a secondary different address and confirmed.
Entering rails console I can lookup the user ID but don’t know how to list the multiple alternate e-mail addresses and strip one of them. Via the UI doesn’t work probably because the e-mail addresses are the same.
Hi yes that is exactly what I am trying to do. In the console I can lookup the user. But how I can then query for the multiple emails addresses and the remove the redundant one I don’t know.
When I select the user I don’t see the emails it must be in some other record.
The email addresses are in the user_emails table. You can find them with the ID of the user:
UserEmail.where(user_id: <user_id>)
Replace <user_id> in the command above with the user’s ID.
Find the id value of the UserEmail record that you want to remove. With that ID, run the following to return the individual record that you want to remove:
Double check the result that is returned to confirm it’s the email you want to remove. Then run:
identical_email.destroy
Before running any destructive commands from the console, it’s a good idea to create a backup of your site’s database. If something goes wrong, you can restore the backup.
Thanks so much, as it turned out I could only fetch one email ID for the duplicate ones. My guess is that the unconfirmed one that I couldn’t remove didn’t yet got listed with that ID? It is probably a bit in the air with an incomplete validation process?
What I did to resolve was switch the primary to the 2 alternate e-mail address. The unconfirmed duplicate could still not be deleted but when I deleted the confirmed (now former-primary email) also the unconfirmed duplicate one got removed.
Then added the original email address as a secondary and then switched it to be the primary.