1
votes

So, at the moment I have account & email as authentication keys for devise, so the login looks like:

  • Account
  • Email
  • Password

Problem is though, if a user has already been created under one account, it is impossible to add another one under a different account, as the email has already been taken.

How do I set up devise to avoid this problem?

Thanks! Chris

1

1 Answers

1
votes

You can remove the validatable module, and do all the validations (you can see them here https://github.com/plataformatec/devise/blob/master/lib/devise/models/validatable.rb) by itself, changing the line:

validates_uniqueness_of :email, :allow_blank => true, :if => :email_changed?

To

validates_uniqueness_of :email, :allow_blank => true, :if => :email_changed?, :scope => [:account]