Module: Devise::Models::Verifiable

Extended by:
ActiveSupport::Concern
Defined in:
lib/devise/models/verifiable.rb

Overview

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

Defined Under Namespace

Modules: ClassMethods

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.required_fields(klass) ⇒ Object



24
25
26
# File 'lib/devise/models/verifiable.rb', line 24

def self.required_fields(klass)
  klass.fields_for_verification
end

Instance Method Details

#valid_for_verification?Boolean

Returns:

  • (Boolean)


34
35
36
37
38
39
# 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?Boolean

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

Returns:

  • (Boolean)


30
31
32
# File 'lib/devise/models/verifiable.rb', line 30

def verified?
  self.class.fields_for_verification.all? { |field| send("#{field}?") }
end