Module: Devise

Defined in:
lib/devise.rb,
lib/devise/models.rb,
lib/devise/failure.rb,
lib/devise/mapping.rb,
lib/devise/version.rb,
lib/devise/migrations.rb,
lib/devise/strategies/base.rb,
lib/devise/models/confirmable.rb,
lib/devise/models/recoverable.rb,
lib/devise/models/validatable.rb,
lib/devise/controllers/filters.rb,
lib/devise/controllers/helpers.rb,
lib/devise/models/rememberable.rb,
lib/devise/models/authenticatable.rb,
lib/devise/controllers/url_helpers.rb,
lib/devise/strategies/rememberable.rb,
lib/devise/strategies/authenticatable.rb

Defined Under Namespace

Modules: Controllers, Failure, Migrations, Models, Strategies Classes: Mapping

Constant Summary collapse

ALL =
[:authenticatable, :confirmable, :recoverable, :rememberable, :validatable].freeze
CONTROLLERS =

Maps controller names to devise modules

{
  :sessions => :authenticatable,
  :passwords => :recoverable,
  :confirmations => :confirmable
}.freeze
STRATEGIES =
[:rememberable, :authenticatable].freeze
TRUE_VALUES =
[true, 1, '1', 't', 'T', 'true', 'TRUE'].freeze
FLASH_MESSAGES =

Maps the messages types that comes from warden to a flash type.

{
  :unauthenticated => :success,
  :unconfirmed => :failure
}
VERSION =
"0.4.2".freeze

Class Method Summary collapse

Class Method Details

.configure_warden_manager(manager) ⇒ Object

A method used internally to setup warden manager from the Rails initialize block.



67
68
69
70
71
72
73
74
# File 'lib/devise.rb', line 67

def configure_warden_manager(manager) #:nodoc:
  manager.default_strategies *Devise::STRATEGIES
  manager.failure_app = Devise::Failure
  manager.silence_missing_strategies!

  # If the user provided a warden hook, call it now.
  @warden_config.try :call, manager
end

.default_url_options(&block) ⇒ Object

Configure default url options to be used within Devise and ActionController.



61
62
63
# File 'lib/devise.rb', line 61

def default_url_options(&block)
  Devise::Mapping.metaclass.send :define_method, :default_url_options, &block
end

.mail_sender=(value) ⇒ Object

:nodoc:



34
35
36
37
# File 'lib/devise.rb', line 34

def mail_sender=(value) #:nodoc:
  ActiveSupport::Deprecation.warn "Devise.mail_sender= is deprecated, use Devise.mailer_sender instead"
  DeviseMailer.sender = value
end

.mailer_sender=(value) ⇒ Object Also known as: sender=

Sets the sender in DeviseMailer.



40
41
42
# File 'lib/devise.rb', line 40

def mailer_sender=(value)
  DeviseMailer.sender = value
end

.setup {|_self| ... } ⇒ Object

Default way to setup Devise. Run script/generate devise_install to create a fresh initializer with all configuration values.

Yields:

  • (_self)

Yield Parameters:

  • _self (Devise)

    the object that the method was called on



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

def setup
  yield self
end

.warden(&block) ⇒ Object

Sets warden configuration using a block that will be invoked on warden initialization.

Devise.initialize do |config|
  config.confirm_within = 2.days

  config.warden do |manager|
    # Configure warden to use other strategies, like oauth.
    manager.oauth(:twitter)
  end
end


56
57
58
# File 'lib/devise.rb', line 56

def warden(&block)
  @warden_config = block
end