This project is archived and is in readonly mode.
New router DSL doesn't propagate requirements to nested resources
-
Wincent Colaiuta
Ok, according to
git bisectthis commit is the one that introduced the regression:commit c6843e23373c626ae49ad9fa253d4f7538d3434f Author: Andrew White <andyw@pixeltrix.co.uk> Date: Sun Jul 4 06:52:52 2010 +0100 Refactor resource options and scoping. Resource classes are now only responsible for controlling how they are named. All other options passed to resources are pushed out to the scope. Signed-off-by: José Valim <jose.valim@gmail.com> -
Andrew White
- Milestone cleared.
- State changed from new to open
- Assigned user set to Andrew White
- Importance changed from to High
What's happening is that the id regexp is getting pulled into the options hash in the scope rather than the constraints hash. I'm guessing that the same will happen for the defaults hash as well. We probably need to scan the options hash passed to the resources call and extract appropriately before pushing them into the scope.
I can't get to it before the weekend as I've a major deadline to meet - if it can wait till then I'll work up a patch. However in the meantime here's a couple of nicer workarounds:
resources :articles, :constraints => { :id => /[^\/]+/ } , :path => 'wiki' do resources :comments, :only => [ :create, :new ] endconstraints(:id => /[^\/]+/) do resources :articles, :path => 'wiki' do resources :comments, :only => [ :create, :new ] end end -
Wincent Colaiuta
Sure it can wait, especially seeing as there are workarounds. Thanks for the analysis. I don't really feel like I know the router well enough to be of much help in coding this up, but I can at least try to come up with a failing test case for it.
-
Andrew White
- Tag set to rails 3.0, constraints, patch, resources, routing
Sorry for the delay, but here's a patch that fixes the problem. Turns out that defaults work okay, it's just regexps that need moving to the constraints hash. Patch applies cleanly to both master and stable.
-
Andrew White
- Assigned user changed from Andrew White to José Valim
-
Repository
- State changed from open to resolved
(from [c019db8ca1c5639fdae80915cc7520eaad7dcd65]) Move regexps in options hash to :constraints hash so that they are pushed into the scope [#5208 state:resolved]
Signed-off-by: José Valim jose.valim@gmail.com
http://github.com/rails/rails/commit/c019db8ca1c5639fdae80915cc7520... -
Repository
(from [6b52a58f726955d5a245b2a9b0b6c5120e3f31d6]) Move regexps in options hash to :constraints hash so that they are pushed into the scope [#5208 state:resolved]
Signed-off-by: José Valim jose.valim@gmail.com
http://github.com/rails/rails/commit/6b52a58f726955d5a245b2a9b0b6c5... -
Wincent Colaiuta
- Assigned user changed from José Valim to Andrew White
Just tried it out and can confirm that this fixes the issue I originally reported. Thanks a lot Andrew.
-
Wincent Colaiuta
(Bah, stupid Lighthouse... yet another unintended user assignment change...)
