Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

fields_for returns block result when outside ERB

Signed-off-by: wycats <wycats@gmail.com>
  • Loading branch information...
commit e5f392ce8ffe2a7fd3bd920132c4cdba8d207a4a 1 parent 59c6082
@ryanb ryanb authored wycats committed
View
2  actionpack/lib/action_view/helpers/form_helper.rb
@@ -528,7 +528,7 @@ def fields_for(record_or_name_or_array, *args, &block)
builder = options[:builder] || ActionView::Base.default_form_builder
- with_output_buffer do
+ capture do
yield builder.new(object_name, object, self, options, block)
end
end
View
5 actionpack/test/template/form_helper_test.rb
@@ -1518,6 +1518,11 @@ def test_form_for_with_existing_object_and_custom_url
assert_equal expected, output_buffer
end
+ def test_fields_for_returns_block_result
+ output = fields_for(Post.new) { |f| "fields" }
+ assert_equal "fields", output
+ end
+
protected
def comments_path(post)
"/posts/#{post.id}/comments"

0 comments on commit e5f392c

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