Godzilla74
Godzilla74

Reputation: 2502

Devise: Email has already been taken but user deleted

I am using Devise for my user models and I've deleted a user from my admin panel, and confirmed that the user is no longer in the DB using rails console. However, when I try to re-create the user (they want to sign up again), I'm presented with a flash error message:

User failed to be created

  • Email has already been taken

Checking the DB again, the user still isn't there:

irb(main):007:0> User.find_by(email: '[email protected]')
=> nil

Why is this happening and what can I do to fix this? Does Devise keep a ghosted user somewhere that I'm not aware of?

Thanks, Justin

Upvotes: 1

Views: 597

Answers (1)

Godzilla74
Godzilla74

Reputation: 2502

As it turns out, someone had installed the Paranoia gem. So I had to find the user:

User.with_deleted.where(email: "[email protected]")

to get the id, then restore:

User.restore(the_id)

Upvotes: 2

Related Questions