module Devise::Models::Verifiable

Verifiable is responsible to add a second step to user sign up process. This module is used when extra information is needed at sign up, e.g. full name, address, documents, etc. Since this adds a second step, the user will be able to finish the registration afterwards.

Options

Verifiable adds the following options to devise:

* +fields_for_verification+: A list of fields which have to be filled
  in the second step of the registration process by the user. These
  fields will be used to build the form in the second screen.

Examples

User.find(1).verified?   # true/false

Public Class Methods

required_fields(klass) click to toggle source
# File lib/devise/models/verifiable.rb, line 24
def self.required_fields(klass)
  klass.fields_for_verification
end

Public Instance Methods

valid_for_verification?() click to toggle source
# File lib/devise/models/verifiable.rb, line 34
def valid_for_verification?
  self.class.fields_for_verification.each do |field|
    validate_for_verification(field)
  end
  errors.empty?
end
verified?() click to toggle source

Determine if the user filled the fields required in the second sign up step

# File lib/devise/models/verifiable.rb, line 30
def verified?
  self.class.fields_for_verification.all? { |field| send("#{field}?") }
end

Protected Instance Methods

validate_for_verification(field) click to toggle source
# File lib/devise/models/verifiable.rb, line 43
def validate_for_verification(field)
  errors.add(field, I18n.t('errors.messages.blank')) if send(field).blank?
end