-
Notifications
You must be signed in to change notification settings - Fork 21.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
AbstractController#internal_methods: ignore action_methods #48699
AbstractController#internal_methods: ignore action_methods #48699
Conversation
c574779
to
2c3504b
Compare
Thanks, LGTM! FYI, if you have time (and want to ofc) this issue #44867 is similar and after merging the change you made in this PR, it will be very easy to fix. |
I had a look at this, and came up with some questions. It seems like the path forward on #44867 would be to remove the monkey-patched
And the following test Does that make sense? Or am I just missing something obvious 🤔 |
Thanks for looking @zzak. Regarding #44867, yes, just removing the overwritten BTW, I'm also just realising that there is a PR open in #44868 for this issue |
Hey all, just popping in to say that based on a quick bisect, this may have caused one Devise test to choke on main:
I'm still digging, but wanted to mention it. This is the test: And this is the All other controllers inherit from it, and if I'm understanding the change correctly, Devise should flag that controller as I'm guessing this wasn't a problem before because |
That sounds right to me. |
@carlosantoniodasilva Random question, but is that controller generated or just inherited inside apps? |
@rafaelfranca thanks, I'm giving that a shot and it does make the test pass, although it makes me wonder if it can cause any issue down the road with it inheriting from, say, So we basically will have other controllers with something like this: Devise::RegistrationsController # final controller/implementation (if not inherited by application itself)
DeviseController # abstract
ApplicationController # implementation
ActionController::Base # abstract The logic that runs @zzak that's a "base" controller which all other Devise controllers inherit from, it's not generated inside apps. |
That is an excelent question and I think your interpretation is correct. Public methods in Any suggestion of what we should do here? |
Sorry that I can’t check myself, I’m with limited network and no laptop for
a few days.
Would it be possible to make the resources method (_prefixes) private
instead of public?
Le mer. 13 sept. 2023 à 09:32, Rafael Mendonça França <
***@***.***> a écrit :
… although it makes me wonder if it can cause any issue down the road with
it inheriting from, say, ApplicationController, which is not abstract.
That is an excelent question and I think your interpretation is correct.
Public methods in ApplicationController will not longer be part of
action_methods. I'm not sure if that is common though, but it is possible
this change will break those apps.
Any suggestion of what we should do here?
—
Reply to this email directly, view it on GitHub
<#48699 (comment)>, or
unsubscribe
<https://github.com/notifications/unsubscribe-auth/AB567BTNSJPBLZTODOSFBW3X2HGXDANCNFSM6AAAAAA2DVJW2I>
.
You are receiving this because you commented.Message ID:
***@***.***>
|
I also didn't properly check, but I think Rails call it internally outside of the controller. |
On Devise, you mean? It's made public because Rails makes it public, but we can probably bet that's just one method that we happen to override, there may be others out there.
I am not sure, will try to think about it more... it's not common (maybe not even expected) to have "abstract -> non-abstract -> abstract -> non-abstract" inheritance. Generally speaking abstract is the last layer, or at least that's how it's interpreted by the implementation(s). We could potentially have the implementation walk up the chain and not stopping at the first abstract class, but that might seem a bit odd. Or I could just have Devise also override |
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: rails/rails#48699
This PR fixes
AbstractController#internal_methods
to excludeaction_methods
.Motivation / Background
I tried enabling
raise_on_missing_callback_actions
and I found out thatMyController#action_methods
is missing a method thatMyController
actually defines. It only happens when a method is also defined by an ancestor abstract controller.xref #48559 (comment)
Checklist
Before submitting the PR make sure the following are checked:
[Fix #issue-number]