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