Routing: custom `param` option for `resources` DSL does not apply to statements in block
jas14 opened this issue · 1 comments
jas14 commented
Checklist
- Upgrade Jets: Are you using the latest version of Jets? This allows Jets to fix issues fast. There's a
jets upgrade
command that makes this a simple task. There's also an Upgrading Guide: http://rubyonjets.com/docs/upgrading/ - Reproducibility: Are you reporting a bug others will be able to reproduce and not asking a question. If you're unsure or want to ask a question, do so on https://community.rubyonjets.com
- Code sample: Have you put together a code sample to reproduce the issue and make it available? Code samples help speed up fixes dramatically. If it's an easily reproducible issue, then code samples are not needed. If you're unsure, please include a code sample.
My Environment
Software | Version |
---|---|
Operating System | macOS 10.15.5 (Catalina) |
Jets | 2.3.16 |
Ruby | 2.5.7, 2.5.8 |
Expected Behaviour
I expect the following route definition:
resources :test, only: [], param: :my_param do
get :somewhere, on: :member
end
to produce the following routing table:
+----------------+------+-------------------------+-------------------+
| As | Verb | Path | Controller#action |
+----------------+------+-------------------------+-------------------+
| somewhere_test | GET | test/:my_param/somewhere | test#somewhere |
+----------------+------+-------------------------+-------------------+
Current Behavior
The above route definition produces:
+----------------+------+-------------------------+-------------------+
| As | Verb | Path | Controller#action |
+----------------+------+-------------------------+-------------------+
| somewhere_test | GET | test/:test_id/somewhere | test#somewhere |
+----------------+------+-------------------------+-------------------+
The path param is named :test_id
instead of :my_param
.
Step-by-step reproduction instructions
- Create a new Jets project and overwrite
config/routes.rb
with the sample below. bundle exec jets routes
- Observe the incorrect route
Code Sample
# config/routes.rb
Jets.application.routes.draw do
resources :test, param: :my_param, only: [] do
get :somewhere, on: :member
end
end
I'm happy to also provide a patch to spec/lib/jets/router_spec.rb
to easily and quickly reproduce the problem.
jas14 commented
I'm considering adding :param
to scope options so we can refer to it in Jets::Router::Scope#full_prefix
. Any objections?