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.



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_mappingObject

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

#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

#resource_paramsObject



31
32
33
# File 'app/controllers/devise_controller.rb', line 31

def resource_params
  params[resource_name]
end

#signed_in_resourceObject

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