How does form_for capture the block?

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

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

http://railscasts.com/episodes/40

Yielding to the view is all that is required.

My face is sure red :wink: