Module: Devise::Controllers::InternalHelpers

Extended by:
ActiveSupport::Concern
Includes:
ScopedViews, SharedHelpers
Included in:
Devise::ConfirmationsController, OmniauthCallbacksController, PasswordsController, RegistrationsController, SessionsController, UnlocksController
Defined in:
lib/devise/controllers/internal_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.

Constant Summary

Constants included from SharedHelpers

SharedHelpers::MIME_REFERENCES

Instance Method Summary collapse

Instance Method Details

#devise_controller?Boolean

Overwrites devise_controller? to return true

Returns:

  • (Boolean)


50
51
52
# File 'lib/devise/controllers/internal_helpers.rb', line 50

def devise_controller?
  true
end

#devise_mappingObject

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



45
46
47
# File 'lib/devise/controllers/internal_helpers.rb', line 45

def devise_mapping
  @devise_mapping ||= request.env["devise.mapping"]
end

#resourceObject

Gets the actual resource stored in the instance variable



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

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

#resource_classObject

Proxy to devise map class



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

def resource_class
  devise_mapping.to
end

#resource_nameObject Also known as: scope_name

Proxy to devise map name



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

def resource_name
  devise_mapping.name
end

#signed_in_resourceObject

Returns a signed in resource from session (if one exists)



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

def signed_in_resource
  warden.authenticate(:scope => resource_name)
end