aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRyan Bates <ryan@railscasts.com>2010-04-10 11:05:42 -0700
committerwycats <wycats@gmail.com>2010-04-11 19:26:00 -0700
commite5f392ce8ffe2a7fd3bd920132c4cdba8d207a4a (patch)
tree84de6c4ae26ebc2e6882c20c7ffbc9ecb7defb5b
parent59c6082d9867572352e2ac2070d5aa9590132ef8 (diff)
downloadrails-e5f392ce8ffe2a7fd3bd920132c4cdba8d207a4a.tar.gz
rails-e5f392ce8ffe2a7fd3bd920132c4cdba8d207a4a.tar.bz2
rails-e5f392ce8ffe2a7fd3bd920132c4cdba8d207a4a.zip
fields_for returns block result when outside ERB
Signed-off-by: wycats <wycats@gmail.com>
-rw-r--r--actionpack/lib/action_view/helpers/form_helper.rb2
-rw-r--r--actionpack/test/template/form_helper_test.rb5
2 files changed, 6 insertions, 1 deletions
diff --git a/actionpack/lib/action_view/helpers/form_helper.rb b/actionpack/lib/action_view/helpers/form_helper.rb
index 80a00b2a10..46b2902fb1 100644
--- a/actionpack/lib/action_view/helpers/form_helper.rb
+++ b/actionpack/lib/action_view/helpers/form_helper.rb
@@ -528,7 +528,7 @@ module ActionView
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
diff --git a/actionpack/test/template/form_helper_test.rb b/actionpack/test/template/form_helper_test.rb
index 28a13b07be..47ac911540 100644
--- a/actionpack/test/template/form_helper_test.rb
+++ b/actionpack/test/template/form_helper_test.rb
@@ -1518,6 +1518,11 @@ class FormHelperTest < ActionView::TestCase
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"