This project is archived and is in readonly mode.
[PATCH] respond_with with array of resources not working
-
Wojciech Wnętrzak
Additional patch with test
-
Wojciech Wnętrzak
I forgot to add require 'active_support/core_ext/array/wrap' for patch with fix.
This patch should be used instead. -
José Valim
- State changed from new to invalid
- Assigned user set to José Valim
- Importance changed from to Low
Rails allows you to use respond_with([@admin, @post]) but Rails interprets it as a collection. The same as if you do: respond_with(Article.all).
That said, if you want to say you are redirecting to a nested resource, you have to do: respond_with(@admin, @post). Therefore, [[arg1, arg2]] is not wrong and the test that fails after your change is correct.
-
Wojciech Wnętrzak
One more question:
Let's say we have responder in create action like:
And object @post has errors - it wont be detected and instead of 422, we get 301 - is it intentional?respond_with([:admin, @post])Also note about similarity of method respond_with to polymorphic_url is little misleading - there we can pass only array if we need nesting.
Documentation -
José Valim
Yes, it is intentional in the sense you should use respond_with(@admin, @post) instead. I agree with you about the note being misleading, I have just removed it. Thanks!
