I followed Devise’s instructions for using usernames in addition to emails for logins. Works great except people can signup with duplicate usernames. If someone tries to signup with a duplicate email address, they are presented with this error message on the signup page:
1 error prohibited this user from being saved:
Email has already been taken
I want something very similar for usernames. How do I implement this?
You should use uniqueness validator. Add following into user.rb:
more about this validator