# module Devise::Models

### Public Instance Methods

devise(*modules) click to toggle source

Include the chosen devise modules in your model:

    devise :database_authenticatable, :confirmable, :recoverable

You can also give any of the devise configuration values in form of a hash, with specific values for this model. Please check your Devise initializer for a complete description on those values.

    # File lib/devise/models.rb, line 50
    def devise(*modules)
      options = modules.extract_options!.dup

      selected_modules = modules.map(&:to_sym).uniq.sort_by do |s|
        Devise::ALL.index(s) || -1  # follow Devise::ALL order
      end

      devise_modules_hook! do
        include Devise::Models::Authenticatable
        selected_modules.each do |m|
          mod = Devise::Models.const_get(m.to_s.classify)

          if mod.const_defined?("ClassMethods")
            class_mod = mod.const_get("ClassMethods")
            extend class_mod

            if class_mod.respond_to?(:available_configs)
              available_configs = class_mod.available_configs
              available_configs.each do |config|
                next unless options.key?(config)
                send(:"#{config}=", options.delete(config))
              end
            end
          end

          include mod
        end

        self.devise_modules |= selected_modules
        options.each { |key, value| send(:"#{key}=", value) }
      end
    end

devise_modules_hook!() { || ... } click to toggle source

The hook which is called inside devise. So your ORM can include devise compatibility stuff.

    # File lib/devise/models.rb, line 85
    def devise_modules_hook!
      yield
    end