I can validate the phone_number for uniqueness like this in the model :
validates :phone_number, :uniqueness => true
The problem is that none of the users in the database have a phone number, and so they are all empty. While loading the page, without entring any phone number, I keep getting the following validation error :
Validation failed: Phone number has already been taken
Seems like it’s even applying the validation for empty phone numbers.
How can I modify the validation to only apply to non-empty phone numbers in the params ?
Either this:
passes if phone_number is nil (or NULL in database), or this:
passes if phone_number is nil or empty string