Class: User

Inherits:
ApplicationRecord
  • Object
show all
Defined in:
app/models/user.rb

Instance Method Summary collapse

Instance Method Details

#authenticate(password) ⇒ Object



49
50
51
# File 'app/models/user.rb', line 49

def authenticate password
  self&.valid_password?(password) ? self : nil
end

#check_password_and_confirmation_equalObject



53
54
55
# File 'app/models/user.rb', line 53

def check_password_and_confirmation_equal
  errors.add(:password, I18n.t("validation.errors.password_and_confirm_must_be_the_same")) unless password == password_confirmation
end

#display_nameObject



41
42
43
# File 'app/models/user.rb', line 41

def display_name
  email
end

#has_role?(role) ⇒ Boolean



45
46
47
# File 'app/models/user.rb', line 45

def has_role? role
  roles.include? role.to_s
end