module Devise::Models::ValidatableWithPersonEmail

ValidatableWithPersonEmail

A re-implementation of Devise::Models::Validatable, but instead of
expecting the `email` field to be in the authenticatable model, is located
instead in the `Person` associated model

Protected Instance Methods

password_required?() click to toggle source

Checks whether a password is needed or not. For validations only. Passwords are always required if it's a new record, or if the password or confirmation are being set somewhere.

# File lib/devise/models/validatable_with_person_email.rb, line 31
def password_required?
  !persisted? || !password.nil? || !password_confirmation.nil?
end
person_email_must_be_present() click to toggle source
# File lib/devise/models/validatable_with_person_email.rb, line 35
def person_email_must_be_present
  return if person&.email.present?
  errors.add :base, 'Person email must be present'
end