This project is archived and is in readonly mode.
Rails 3.0.0, 'yield' won't show block contents in render :layout, if it is placed after render :partial
Reported by Anton Astashov | September 5th, 2010 @ 03:03 PM | in 3.0.5
After migrating to Rails 3.0.0, following code doesn't work correctly anymore:
# app/views/layouts/_example_layout.html.erb
Before
<%= render :partial => "/example_partial.html.erb" %>
<%= yield %>
After
# app/views/_example_partial.html.erb
<%= "It is partial" %>
# app/views/example/index.html.erb
<%= render :layout => "/layouts/example_layout" do %>
<%= "Block's content" %>
<% end %>
It will display:
Before
It is partial
After
instead of:
Before
It is partial
Block content
After
Looks like the reason of the issue is reusing of the PartialRenderer object in ActionView::Partials#_render_partial method and setting up empty block of render :partial (instead of real block of render :layout) to it.
Test for the issue is attached.
Comments and changes to this ticket
-
Marjan Krekoten' September 5th, 2010 @ 05:13 PM
- Assigned user set to Santiago Pastorino
- Tag changed from block, layout, partial, render to block, layout, partial, patch, render
Fix attached. Also contains test case from Anton Astashov.
-
David Trasbo September 5th, 2010 @ 06:54 PM
+1
Patch applies cleanly and the included test fails without the fix but passes with it.
-
José Valim September 5th, 2010 @ 07:42 PM
- Milestone set to 3.x
- State changed from new to open
- Assigned user changed from Santiago Pastorino to Yehuda Katz (wycats)
- Importance changed from to Low
Unfortunately this fix hits performance. Do we have other options?
-
Anton Astashov September 6th, 2010 @ 02:22 AM
Maybe we can pass a block right to ActionView::Partials::PartialRenderer#render instead of passing it to initialize/setup methods? Please take a look at the attached path.
-
bfalling November 25th, 2010 @ 05:11 AM
+1
I don't know how others are working around this, but this bug has bitten us in a number of apps.
Thanks!
-
Tyler McGill January 24th, 2011 @ 03:33 AM
This just killed 5 hours of development time for me. I'm glad I found this bug report. I'm using 3.0.3. Any update on status?
-
Santiago Pastorino January 31st, 2011 @ 09:33 PM
- Milestone cleared.
- Assigned user changed from Yehuda Katz (wycats) to Santiago Pastorino
Anton, the patch looks good to me. I'm going to apply it, but doesn't apply cleanly now :'(.
Can you rebase it to master and 3-0-stable?. Thanks. -
Santiago Pastorino February 2nd, 2011 @ 08:03 PM
Guys the release is going to happen tomorrow please send a rebased patch :).
-
Anton Astashov February 3rd, 2011 @ 02:39 AM
Good news - I've applied tests from the patch to 'master' and '3-0-stable' (only the tests, not the actual code), and they passed, all tests are passed. Also, tried to create demo rails app and check this issue there - it works fine. So, looks like the ticket can be closed - this issue was fixed already. Hooray! :)
-
Santiago Pastorino February 3rd, 2011 @ 11:55 AM
Anton cool, so can you provide a patch with only tests so we can be sure to avoid a regression?
-
Repository February 3rd, 2011 @ 02:58 PM
- State changed from open to resolved
(from [c1c6f29214d3c280f5d1d4abb49d0b90424fcbd7]) Add a test for 'render :layout'
To make sure it will show block contents if it is placed after 'render
:partial'[#5557 state:resolved]
Signed-off-by: Santiago Pastorino santiago@wyeworks.com
https://github.com/rails/rails/commit/c1c6f29214d3c280f5d1d4abb49d0... -
Repository February 3rd, 2011 @ 03:11 PM
(from [53b0235282ebb4953ef2e0644e64c232ec902ef2]) Add a test for 'render :layout'
To make sure it will show block contents if it is placed after 'render
:partial'[#5557 state:resolved]
Signed-off-by: Santiago Pastorino santiago@wyeworks.com
https://github.com/rails/rails/commit/53b0235282ebb4953ef2e0644e64c...
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>