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.

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.internal_methodsObject

Override internal methods to exclude ‘_prefixes` from action methods since we override it above.

There was an intentional change in Rails 7.1 that will allow it to become an action method because it’s a public method of a non-abstract controller, but we also can’t make this abstract because it can affect potential actions defined in the parent controller, so instead we ensure ‘_prefixes` is going to be considered internal. (and thus, won’t become an action method.) Ref: github.com/rails/rails/pull/48699



45
46
47
# File 'app/controllers/devise_controller.rb', line 45

def self.internal_methods #:nodoc:
  super << :_prefixes
end

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.

This method should be public as it is in ActionPack itself. Changing its visibility may break other gems.



28
29
30
31
32
33
34
# File 'app/controllers/devise_controller.rb', line 28

def _prefixes #:nodoc:
  @_prefixes ||= if self.class.scoped_views? && request && devise_mapping
    ["#{devise_mapping.scoped_path}/#{controller_name}"] + super
  else
    super
  end
end