Class: DeviseController
- Inherits:
-
Object
- Object
- DeviseController
- Includes:
- Devise::Controllers::ScopedViews
- Defined in:
- app/controllers/devise_controller.rb
Overview
All Devise controllers are inherited from here.
Direct Known Subclasses
Devise::ConfirmationsController, Devise::OmniauthCallbacksController, Devise::PasswordsController, Devise::RegistrationsController, Devise::SessionsController, Devise::UnlocksController
Instance Method Summary collapse
-
#_prefixes ⇒ Object
Override prefixes to consider the scoped view.
-
#devise_mapping ⇒ Object
Attempt to find the mapped route for devise based on request path.
-
#resource ⇒ Object
Gets the actual resource stored in the instance variable.
-
#resource_class ⇒ Object
Proxy to devise map class.
-
#resource_name ⇒ Object
(also: #scope_name)
Proxy to devise map name.
-
#signed_in_resource ⇒ Object
Returns a signed in resource from session (if one exists).
Instance Method Details
#_prefixes ⇒ Object
Override prefixes to consider the scoped view. Notice we need to check for the request due to a bug in Action Controller tests that forces _prefixes to be loaded before even having a request object.
45 46 47 48 49 50 51 |
# File 'app/controllers/devise_controller.rb', line 45 def _prefixes #:nodoc: @_prefixes ||= if self.class.scoped_views? && request && devise_mapping super.unshift("#{devise_mapping.scoped_path}/#{controller_name}") else super end end |
#devise_mapping ⇒ Object
Attempt to find the mapped route for devise based on request path
37 38 39 |
# File 'app/controllers/devise_controller.rb', line 37 def devise_mapping @devise_mapping ||= request.env["devise.mapping"] end |
#resource ⇒ Object
Gets the actual resource stored in the instance variable
16 17 18 |
# File 'app/controllers/devise_controller.rb', line 16 def resource instance_variable_get(:"@#{resource_name}") end |
#resource_class ⇒ Object
Proxy to devise map class
27 28 29 |
# File 'app/controllers/devise_controller.rb', line 27 def resource_class devise_mapping.to end |
#resource_name ⇒ Object Also known as: scope_name
Proxy to devise map name
21 22 23 |
# File 'app/controllers/devise_controller.rb', line 21 def resource_name devise_mapping.name end |
#signed_in_resource ⇒ Object
Returns a signed in resource from session (if one exists)
32 33 34 |
# File 'app/controllers/devise_controller.rb', line 32 def signed_in_resource warden.authenticate(:scope => resource_name) end |