I have a form to add clients and enter their email. The email is not
required but should be unique, so I have this at the model.
CLIENT
validates :email, :uniqueness => true
Some clients have NO email on record. So when I try to add a second
client with no email, I get this validation message: “Email has already
been taken”. I supposed because this happens because sees a current
empty email row and then I’m submitting an empty email field so it they
are not unique anymore because they are both empty.
How can I allow for empty email fields but also check for uniqueness?
Not sure about that last part, but do you see what I’m trying for
there? You might need to make a controller-level function to check if
the current item has an empty e-mail property.