improve user email validation

This commit is contained in:
Alex Turchyn
2025-05-28 19:11:39 +03:00
committed by Pete Matsyburka
parent 8b9678a434
commit fa0733f480
4 changed files with 37 additions and 0 deletions
+2
View File
@@ -73,6 +73,8 @@ class User < ApplicationRecord
scope :archived, -> { where.not(archived_at: nil) }
scope :admins, -> { where(role: ADMIN_ROLE) }
validates :email, format: { with: /\A[A-Za-z0-9._%+-]+@[A-Za-z0-9.-]+\.[A-Za-z]{2,}\z/ }
def access_token
super || build_access_token.tap(&:save!)
end