mirror of
https://github.com/heartcombo/devise.git
synced 2026-01-09 23:08:05 -05:00
Ensure _prefixes is not available as an action method on controllers
There was a change introduced in Rails 7.1 that causes all public actions of non-abstract controllers to become action methods, even if they happen to match the name of an internal method defined by abstract `ActionController::Base` and such, which is the case with `_prefixes`. This change was intentional, it allows for example to have an action called `status`, which is an internal method, and that is properly managed as an action method now. However, it broke Devise due to overriding `_prefixes`, which is a public method of Action Controller. To fix, we are simply ensuring we keep `_prefixes` as an internal method rather than action method, which matches previous behavior for this particular method/implementation in Devise. Ref: https://github.com/rails/rails/pull/48699
This commit is contained in:
@@ -33,6 +33,17 @@ class DeviseController < Devise.parent_controller.constantize
|
||||
end
|
||||
end
|
||||
|
||||
# Override internal methods to exclude `_prefixes` 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: https://github.com/rails/rails/pull/48699
|
||||
def self.internal_methods #:nodoc:
|
||||
super << :_prefixes
|
||||
end
|
||||
|
||||
protected
|
||||
|
||||
# Gets the actual resource stored in the instance variable
|
||||
|
||||
Reference in New Issue
Block a user