Lighthouse has a new layout. Prefer the old one? Return to the old layout, and switch back any time from the link at the top of each page.

This project is archived and is in readonly mode.

Regression in 3.0pre With content_for And Layouts

#3089

A recent commit in trunk for 3.0pre has caused a regression with content_for is used to insert content into a layout. Here is the commit for 9f5cd0156ab907d8097fc9c588823a9b09038b93.

http://github.com/rails/rails/commit/9f5cd0156ab907d8097fc9c588823a...

This is a very common practice and is documented in the code to work. In fact, it is even one of Ryan's early screen casts.

http://railscasts.com/episodes/8-layouts-and-content-for

Reported by Ken Collins · August 24th, 2009 @ 12:53 AM

State: duplicate
Milestone: 3.0.2
Assigned to: Yehuda Katz (wycats) Yehuda Katz (wycats)
Importance: none

Activity

  1. Ken Collins
    Ken Collins

    Here is the patch that includes a passing test before the 9f5cd0 commit. It is still failing the inner template part however. Typically I am in ActiveRecord most of the time and I am not sure what needs to be done bring this to full parity with rails 2.3.4. There seems to much going on and I would appreciate feedback.

    August 24th, 2009 @ 12:56 AM

  2. Michael Koziarski
  3. Jeff Bigler
    Jeff Bigler

    I've been able to duplicate this bug as well using 3.0beta edge. As a matter of fact, it doesn't even require using the content_for tag to see the error. After running a generator to create a simple Posts sample application, I set up a single line layouts/application.html.erb file:

    <%= yield %>
    

    I then created a layouts/posts.html.erb file with only the single line:

    <% render :file => 'layouts/application' %>
    

    and it fails with the LocalJumpError message. The error raised is "no block given". If I delete the layouts/posts.html.erb file everything works fine.

    February 16th, 2010 @ 07:25 AM

  4. Carson Baker
    Carson Baker

    Same problem here. Using render :file and content_for/yield gives "No block given" error.

    February 16th, 2010 @ 11:10 PM

  5. Yehuda Katz (wycats)
    Yehuda Katz (wycats)

    @Carson would you mind creating a patch with a failing test against master?

    February 24th, 2010 @ 07:22 AM

  6. Jeff Bigler
    Jeff Bigler

    This is my first attempt to help out with a patch, so I apologize if there are any problems. I tried creating a test case for ActionPack that demonstrates the failure.

    February 25th, 2010 @ 04:09 AM

  7. Jeff Bigler
    Jeff Bigler

    This appears to be a duplicate of ticket #3459 "yield" doesn't work with content_for_layout and render :file

    The patch provided in that ticket fixed the problem.

    February 26th, 2010 @ 06:05 AM

  8. Santiago Pastorino
    Santiago Pastorino
    • State changed from new to duplicate

    March 4th, 2010 @ 08:52 PM

  9. Jeremy Kemper
    Jeremy Kemper
    • Milestone set to 3.0.2
    • Importance changed from to

    October 15th, 2010 @ 11:01 PM