I followed up Developing instructions for using usernames in addition to login emails . It works great, except that people can register with duplicate usernames. If someone tries to register with a duplicate email address, this error message will be presented on the registration page:
1 error prevented the user from saving:Email has already been taken
1 error prevented the user from saving:
Email has already been taken
I want something very similar to usernames. How to implement this?
You must use a unique validator. Add the following to user.rb:
validates_uniqueness_of :username