-
Notifications
You must be signed in to change notification settings - Fork 3
fix: Support Rails Engines #42
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
base: main
Are you sure you want to change the base?
Conversation
arkirchner
commented
Sep 11, 2025
- RFC6570 paths need to include the Rails Engines prefix.
- Route parameter support keyword arguments and an options Hash.
- RFC6570 paths need to include the Rails Engines prefix. - Route parameter support keyword arguments and an options Hash.
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #42 +/- ##
=========================================
Coverage 100.00% 100.00%
=========================================
Files 4 4
Lines 162 161 -1
=========================================
- Hits 162 161 -1 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
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.
Does the engine need to be a gem? This feels like adding a lot of unrelated churn.
If the engine is only needed in tests, can it be defined/loaded only there?
route.to_rfc6570(**opts, ctx: self, path_only: false) | ||
end | ||
|
||
define_method(rfc6570_path_name) do |**opts| | ||
define_method(rfc6570_path_name) do |opts = {}| |
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.
Why's this needed? 👀
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.
- Support for options hash for
*_rfc6570
to support Rails Engines.
When used in a Rails engine, the options are a hash. I was able to reproduce this issue loading the engine; however, this seems to no longer be the case.
I am investigating.
options = ctx.url_options.merge(kwargs) | ||
options[:path] = parts.join | ||
options[:only_path] = kwargs.fetch(:path_only, false) | ||
|
||
::Addressable::Template.new \ | ||
ActionDispatch::Http::URL.url_for(options) | ||
if (osn = options.delete(:original_script_name)) | ||
options[:script_name] = osn + options[:script_name] | ||
end | ||
|
||
::Addressable::Template.new \ | ||
ActionDispatch::Http::URL.url_for(options) |
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 seems to be the primary change here, but it is very similar to before.
What's the important change here? It handles path_only: true
much more like a full URL? Is that the important change for supporting engines?
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.
Yes, the original version removed the engines mount path.
/some_engine/users
was resolved to just /users
.
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.
Fix up
*_path_rfc6570
to include Rails Engines mount point.
Basically the previous version would ignore script_name
for paths.
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.
Thank you for contributing!
I've added some notes and would need some more clarification about which specific changes do what. I do need to understand the changes and intentions so that I can continue to maintain that.
Please add them to the commit(s) and PR description so that they are preserved.