16 lines
458 B
Ruby
16 lines
458 B
Ruby
class User < ApplicationRecord
|
|
has_secure_password
|
|
|
|
validates :username, presence: true, length: { minimum: 3, maximum: 50 }
|
|
validates :email, presence: true,
|
|
uniqueness: { case_sensitive: false },
|
|
format: { with: URI::MailTo::EMAIL_REGEXP }
|
|
validates :password, length: { minimum: 6 }, if: -> { new_record? || !password.nil? }
|
|
|
|
before_save { self.email = email.downcase }
|
|
|
|
def admin?
|
|
admin
|
|
end
|
|
end
|