ruby-on-railsdevisecas

PG::UniqueViolation error with Devise and devise_cas_authenticable


I configured my Rails app to authenticate through CAS. I use the Devise gem and the devise_cas_authenticable gem. However when anyone in my organisation tries to authenticate, this error appears:

PG::UniqueViolation: ERROR:  duplicate key value violates unique constraint "index_users_on_email"

Does anyone have experience with this error and how it can be solved?

thanks for your help,

Anthony Candael


Solution

  • Remove the unique index on users.email. You are probably identifying users by username, not by email address (which might be nil, hence the unique constraint validation).