This project is archived and is in readonly mode.
Wrong redirect after creation of nested singleton resource (using responder)
-
José Valim
- Assigned user set to José Valim
- Milestone cleared.
The problem is not in responder, but in url generation. Try doing this:
url_for [@post, @approval]What does it return you?
-
Ingo
yes, the above returns '/posts/1/approval.1'
-
José Valim
- Assigned user changed from José Valim to josh
- State changed from new to open
-
josh
- Assigned user cleared.
-
jonshea (at expandrive)
There’s a very similar test case in polymorphic_routes_test.rb. The method
test_nesting_with_array_ending_in_singleton_resourcetests the result ofpolymorphic_url([@project, :bid]), where Project is a plural resource and Bid is a singular resource. This test passes with the expected result,http://example.com/projects/16/bid.If the test is modified to use
[@project, @bid]instead of[@project, :bid]then it fails as described above (http://example.com/projects/16/bid.17).I don’t know if perhaps it’s “wrong” for some reason to use an object for the singular resource instead of the symbol, but I’ve attached a patch for the modified test case regardless. If this is a real issue, then I’d be happy to look into the fix as well.
-
José Valim
- State changed from open to wontfix
@Jonshea, this is actually a known bug, since early Rails versions. We know how to reproduce it, but the solution is quite difficult, since polymorphic_url/url_for would have to ask the router how to mount it.
-
Brendon
+1 This happens even when the singular resource is earlier in the array.
