mirror of
https://github.com/SrIzan10/hc-harbor.git
synced 2026-05-01 10:45:21 +00:00
22 lines
391 B
Ruby
22 lines
391 B
Ruby
class EmailAddress < ApplicationRecord
|
|
belongs_to :user
|
|
|
|
validates :email, presence: true,
|
|
uniqueness: true,
|
|
format: { with: URI::MailTo::EMAIL_REGEXP }
|
|
|
|
enum :source, {
|
|
signing_in: 0,
|
|
github: 1,
|
|
slack: 2
|
|
}, prefix: true
|
|
|
|
before_validation :downcase_email
|
|
|
|
private
|
|
|
|
def downcase_email
|
|
self.email = email.downcase
|
|
end
|
|
end
|