This project is archived and is in readonly mode.

#4777 ✓resolved
Travis

render(:inline) in a layout before yield replaces original content

Reported by Travis | June 6th, 2010 @ 04:52 PM | in 3.0.2

The issue I'm seeing is that if you call render(:inline => "some text") in the layout before yielding to the main content for the page, the content of the yield will replace the original content of the page.

Perhaps this is the intended behavior and I just don't understand. I haven't delved into the source yet to see why this is happening, or if using render :inline in a layout is in fact incorrect usage.

Nor have put together tests or a demo to exhibit it, but it's fairly simple to reproduce.

Given a fresh project with a controller 'test' and an #index action.

rails g controller test index

In config/routes.rb

root :to => "test#index"

In app/views/layouts/application.html.erb

<%= render :inline => "layout inline 1" %>
<%= yield %>
<%= render :inline => "layout inline 2" %>

If you start up the server and hit the home page you'll see:

layout inline 1
layout inline 1
layout inline 2

The content in index.html.erb has been replaced by the inline render prior. This does not happen in Rails 2.

Comments and changes to this ticket

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>

Referenced by

Pages