Class: DeviseController

Inherits:
Object
  • Object
show all
Includes:
Devise::Controllers::ScopedViews
Defined in:
app/controllers/devise_controller.rb

Overview

All Devise controllers are inherited from here.

Instance Method Summary collapse

Instance Method Details

#_prefixesObject

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_mappingObject

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

#resourceObject

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_classObject

Proxy to devise map class



27
28
29
# File 'app/controllers/devise_controller.rb', line 27

def resource_class
  devise_mapping.to
end

#resource_nameObject 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_resourceObject

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