I am trying to validate that two columns are unique in my User model. I've searched Google and from what I understand the following code will not work:
validates :login, :uniqueness=>true
validates :email, :uniqueness=>true
In my case doing that will validate the uniqueness of email, but will not validate the uniqueness of login. I set that login must be unique on the database. However, all that will do is generate a runtime error if it already exists. I don't want that error in production because it would result in a 500 internal server error, which the user would not understand.
Any ideas on how I could validate the uniqueness of both of these fields?
Authentication Used:
- CanCan
- Devise
- Devise Invitable
Update:
From what I can tell the problem is being caused by Devise, specifically the validatable module, which validate email and password.
Update 2:
Removing the validatable module from Devise will result in neither checking for uniqueness.
Update 3:
It appears that devise is not causing the problem. Rather, a gem called Devise Invitable is. Removing this gem results in the validation being triggered. It also appears that this gem tries to force validations of the email field. It makes sense due to the nature of this gem, but shouldn't be blocking.