# How does form\_for capture the block?

**URL:** <https://www.ruby-forum.com/t/how-does-form-for-capture-the-block/111518>\
**Category:** Rails\
**Created:** [August 8, 2007, 6:26am UTC](https://www.ruby-forum.com/t/how-does-form-for-capture-the-block/111518 "2007-08-08T06:26:46Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![liquid](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/l/47e85d/32.png) [@liquid](https://www.ruby-forum.com/u/liquid)\
**Post date:** [August 8, 2007, 6:26am UTC](https://www.ruby-forum.com/t/how-does-form-for-capture-the-block/111518/1 "2007-08-08T06:26:46Z")

</div>

I’m stumped as to how form\_for actually captures the block and puts it  
into  
the output.

Looking at the method it’s basically  
form\_for( arg list )  
#…  
concat( “open tag”, block.binding )  
fields\_for( stuff, &block )  
concat( “close tag”, block.binding )  
end

and fields\_for is basically a yield of a builder object.

so it boils down to:  
concat( “open tag”, block.binding )  
yield builder\_object  
concat( “close tag”, block.binding )

There does not seem to be any binding to the current block in the  
builder.  
How does the content of the yield get into the output buffer, let alone  
get  
there in the right place?

Cheers  
Daniel

---

<div class="post-metadata">

**Author:** ![liquid](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/l/47e85d/32.png) [@liquid](https://www.ruby-forum.com/u/liquid)\
**Post date:** [August 8, 2007, 9:37am UTC](https://www.ruby-forum.com/t/how-does-form-for-capture-the-block/111518/2 "2007-08-08T09:37:03Z")

</div>

On 8/8/07, Daniel N [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> end  
> alone get there in the right place?
> 
> Cheers  
> Daniel

I thought I’d follow this one up since I found the answer. Sort of.

> **[\#40 Blocks in View - RailsCasts](http://railscasts.com/episodes/40-blocks-in-view)**
>
> Short Ruby on Rails screencasts containing tips, tricks and tutorials. Great for both novice and experienced web developers.

Yielding to the view is all that is required.

My face is sure red 😉
