-
Notifications
You must be signed in to change notification settings - Fork 21.7k
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
Simplify _prefixes #15026
Simplify _prefixes #15026
Conversation
If the goal is to make |
… up the inheritance chain, classes can override local prefixes.
Totally agree about the proper documentation and testing and I will add that once you give me the OK 😁 Overriding on the instance level is still possible by overriding I don't know what's the deal with those underscored methods, we can remove them, I don't see what they stand for. Thanks for your prompt relpy, @josevalim! |
Underscored methods are private. They are not supposed to be removed if they are meant to be private. |
The problem is that those methods should be public but might interfere with actual controller actions. If I personally find it OK to leave them underscored, just to avoid the hassle with name clashes. Other than that my only concern is that I ruthlessly removed |
Here's what I wanna do.
|
@apotonick seems a good plan. Also I think if |
@rafaelfranca Do you have an example where a method is marked as deprecated if it is defined (in Rails)? I will then inform the user about the deprecation of |
hmmm. I don't think we have this. I thought we want to deprecate the usage not the definition. So I guess the only way if checking when calling |
Yeah, that's what I meant as well - I just thought there's an automation in Rails for that 😉 |
There are some helpers but I prefer to call |
This guy is ready to be merged, @rafaelfranca and @josevalim. |
[controller_path] | ||
end | ||
|
||
def handle_deprecated_parent_prefixes # TODO: remove in 4.3/5.0. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This method should be private
We still need tests overriding |
…ation for overriding ::_parent_prefixes.
I added tests for overriding |
Hi @rafaelfranca - this is ready to be merged, rebased and squashed in https://github.com/apotonick/rails/tree/simplify-prefixes. Thanks ❤️ |
Do you want me to |
Oh, and thanks! |
Yes. For us it is better. |
For me, too! And again, thanks for this prompt and uncomplicated merge, I really really appreciate the "open-ness" in the core towards architectural changes. ❤️ |
Summary
This simplifies the logic to compile the
_prefixes
array used for view inheritance. The change allows overriding::_local_prefixes
which didn't work before.Implementation
It is now implemented with a proper recursion travelling up the inheritance chain instead of doing all the work locally in the concrete controller. Controllers in the chain can now define their local
_prefixes
by overriding_local_prefixes
(we can rename that). This didn't work before.We use this extensively in Cells for the new Trailblazer file layout. I thought it might be helpful to push that back to the core.