Module: Devise::Controllers::Helpers

Included in:
ConfirmationsController, PasswordsController, SessionsController
Defined in:
lib/devise/controllers/helpers.rb

Overview

Those helpers are used only inside Devise controllers and should not be included in ApplicationController since they all depend on the url being accessed.

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.included(base) ⇒ Object



8
9
10
11
12
13
14
15
16
# File 'lib/devise/controllers/helpers.rb', line 8

def self.included(base)
  base.class_eval do
    helper_method :resource, :resource_name, :resource_class, :devise_mapping, :devise_controller?
    hide_action   :resource, :resource_name, :resource_class, :devise_mapping, :devise_controller?

    skip_before_filter *Devise.mappings.keys.map { |m| :"authenticate_#{m}!" }
    before_filter :is_devise_resource?
  end
end

Instance Method Details

#devise_controller?Boolean

Overwrites devise_controller? to return true

Returns:

  • (Boolean)


39
40
41
# File 'lib/devise/controllers/helpers.rb', line 39

def devise_controller?
  true
end

#devise_mappingObject

Attempt to find the mapped route for devise based on request path



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

def devise_mapping
  @devise_mapping ||= Devise::Mapping.find_by_path(request.path)
end

#resourceObject

Gets the actual resource stored in the instance variable



19
20
21
# File 'lib/devise/controllers/helpers.rb', line 19

def resource
  instance_variable_get(:"@#{resource_name}")
end

#resource_classObject

Proxy to devise map class



29
30
31
# File 'lib/devise/controllers/helpers.rb', line 29

def resource_class
  devise_mapping.to
end

#resource_nameObject

Proxy to devise map name



24
25
26
# File 'lib/devise/controllers/helpers.rb', line 24

def resource_name
  devise_mapping.name
end