Class: UserEmailValidator

Inherits:
ActiveModel::Validator
  • Object
show all
Defined in:
app/validators/user_email_validator.rb

Instance Method Summary collapse

Instance Method Details

#validate(record) ⇒ Object


2
3
4
5
6
# File 'app/validators/user_email_validator.rb', line 2

def validate(record)
  if UserEmail.confirmed.where.not(id: record.id).exists?(email: record.email)
    record.errors[:base] << "This email is already being used."
  end
end