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.
- #resource_params ⇒ Object
-
#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.
49 50 51 52 53 54 55 |
# File 'app/controllers/devise_controller.rb', line 49 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
41 42 43 |
# File 'app/controllers/devise_controller.rb', line 41 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 |
#resource_params ⇒ Object
31 32 33 |
# File 'app/controllers/devise_controller.rb', line 31 def resource_params params[resource_name] end |
#signed_in_resource ⇒ Object
Returns a signed in resource from session (if one exists)
36 37 38 |
# File 'app/controllers/devise_controller.rb', line 36 def signed_in_resource warden.authenticate(:scope => resource_name) end |