Skip to content
This repository
Browse code

fields_for returns block result when outside ERB

Signed-off-by: wycats <wycats@gmail.com>
  • Loading branch information...
commit e5f392ce8ffe2a7fd3bd920132c4cdba8d207a4a 1 parent 59c6082
Ryan Bates authored April 10, 2010 wycats committed April 11, 2010
2  actionpack/lib/action_view/helpers/form_helper.rb
@@ -528,7 +528,7 @@ def fields_for(record_or_name_or_array, *args, &block)
528 528
 
529 529
         builder = options[:builder] || ActionView::Base.default_form_builder
530 530
 
531  
-        with_output_buffer do
  531
+        capture do
532 532
           yield builder.new(object_name, object, self, options, block)
533 533
         end
534 534
       end
5  actionpack/test/template/form_helper_test.rb
@@ -1518,6 +1518,11 @@ def test_form_for_with_existing_object_and_custom_url
1518 1518
     assert_equal expected, output_buffer
1519 1519
   end
1520 1520
 
  1521
+  def test_fields_for_returns_block_result
  1522
+    output = fields_for(Post.new) { |f| "fields" }
  1523
+    assert_equal "fields", output
  1524
+  end
  1525
+
1521 1526
   protected
1522 1527
     def comments_path(post)
1523 1528
       "/posts/#{post.id}/comments"

0 notes on commit e5f392c

Please sign in to comment.
Something went wrong with that request. Please try again.