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
Extend routes --grep
to also filter routes by matching against path
#45874
Conversation
Thank you for submitting this! Looks ready for review by a core committer, I've tagged it as such. |
Hi @orhantoy, |
@p8 That could work but there is a downside:
we would also get matches for nested routes like /cats/1/profile .
Both exact and fuzzy would be useful so perhaps I could extend the The reason why I would advocate for the exact match, is because a very common question when starting out with Rails or when trying to understand a new Rails app is: what controller-action is called when I go to Update: I might be wrong about how the current fuzzy match works in
It seems to match against the path pattern, like |
Why to not use system grep like |
@simi If you're talking about the feature I'm proposing here, which is to see which routes a given path resolves to, then grep cannot help. With this feature you can take a real URL path, like If you're talking about the |
@p8 I think reusing the I have updated the PR with the relevant changes. Let me know what you think. |
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.
Looks good to me, just one very minor style concern.
Please squash your commits and I'll merge.
ed57028
to
930e36f
Compare
routes --grep
to also filter routes by matching against path
Looks great @orhantoy ! |
Summary
When looking at a path like
/users/orhantoy/settings
it's not always obvious which controller-action corresponds to this route. So, I thought it would be useful to be able to look up what controller-action matches a given path. Turns out this is actually possible via/rails/info/routes
(news to me!) but I thought it would also come in handy to have the same functionality inrails routes
.Example
Revised after #45874 (comment) (I originally introduced a separate
--path
option):