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.

fields_for not working outside ERB

#4363

If one calls fields_for in a helper method, then the block result is not returned by the method. For example.

# application_helper.rb
def foobar
  fields_for(:object, Object.new) do |f|
    "foobar"
  end
end

Calling <%= foobar %> in the view will not output "foobar" in Rails 3 Beta 2 but it will in Rails 2. This breaks some nested form solutions.

I'll look into submitting a patch, but I think changing with_output_buffer to capture in the fields_for method will do the job.

Reported by Ryan Bates · April 10th, 2010 @ 06:31 PM

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

Activity

  1. Ryan Bates
  2. José Valim
    José Valim
    • Assigned user set to José Valim
    • Milestone cleared.

    April 11th, 2010 @ 10:39 PM

  3. José Valim
    José Valim
    • Assigned user changed from José Valim to Yehuda Katz (wycats)

    Yehuda already applied.

    April 12th, 2010 @ 08:35 AM

  4. Yehuda Katz (wycats)
    Yehuda Katz (wycats)
    • State changed from new to resolved

    April 13th, 2010 @ 05:14 AM

  5. Jeremy Kemper