This project is archived and is in readonly mode.
[PATCH] rendering a partial with an array as its :object should not behave as if it were passed as :collection
Reported by James MacAulay | September 30th, 2010 @ 07:42 PM
This code does not work the same way as it did in 2.x:
render :partial => "things", :object => ['foo', 'bar', 'baz']
In 2.x, the "things" partial would be rendered once with a local variable called "things" storing the given array.
In 3.0.0 (and edge), the Action View assumes that you really meant :collection => ['foo', 'bar', 'baz'], so it iterates through the array and renders the partial once with each element. It will do this for any object which responds to to_ary.
I really think this is a case of Rails being too clever for its own good. The difference in behaviour between the :object and :collection options is large enough that this cleverness makes for a big break in expectations. If someone wants the :collection behaviour, they should use :collection.
Comments and changes to this ticket
-
James MacAulay September 30th, 2010 @ 08:28 PM
- Title changed from rendering a partial with an array as its :object behaves as if it were :collection to [PATCH] rendering a partial with an array as its :object should not behave as if it were passed as :collection
- Tag changed from action_view to action_view, bug
Made a patch to fix this. At first I thought this was an intentional change, but after working with the code more I realize that it's probably just a bug.
-
James MacAulay September 30th, 2010 @ 08:38 PM
- no changes were found...
-
Repository October 7th, 2010 @ 11:12 PM
- State changed from new to resolved
(from [581b2b68368e3330cc725a305d0e2465c2e71e1c]) fix rendering a partial with an array as its :object [#5746 state:resolved]
Signed-off-by: Michael Koziarski michael@koziarski.com
Conflicts:
actionpack/lib/action_view/render/partials.rb
http://github.com/rails/rails/commit/581b2b68368e3330cc725a305d0e24...
-
Repository October 7th, 2010 @ 11:12 PM
(from [2ded862226e1309fc8042b824d388e5bf927d357]) fix rendering a partial with an array as its :object [#5746 state:resolved]
Signed-off-by: Michael Koziarski michael@koziarski.com
http://github.com/rails/rails/commit/2ded862226e1309fc8042b824d388e... -
Ryan Bigg October 11th, 2010 @ 10:54 AM
- Tag cleared.
- Importance changed from to Low
Automatic cleanup of spam.
Create your profile
Help contribute to this project by taking a few moments to create your personal profile. Create your profile »
<h2 style="font-size: 14px">Tickets have moved to Github</h2>
The new ticket tracker is available at <a href="https://github.com/rails/rails/issues">https://github.com/rails/rails/issues</a>
People watching this ticket
Attachments
Referenced by
- 5884 Rendering a partial with an array as its :object should not render as :collection This is fixed in HEAD, this is actually a dupe of #5746
- 5746 [PATCH] rendering a partial with an array as its :object should not behave as if it were passed as :collection (from [581b2b68368e3330cc725a305d0e2465c2e71e1c]) fix ren...
- 5746 [PATCH] rendering a partial with an array as its :object should not behave as if it were passed as :collection (from [2ded862226e1309fc8042b824d388e5bf927d357]) fix ren...