# How does form\_for work?

**URL:** <https://www.ruby-forum.com/t/how-does-form-for-work/132297>\
**Category:** Rails\
**Created:** [March 18, 2008, 10:12pm UTC](https://www.ruby-forum.com/t/how-does-form-for-work/132297 "2008-03-18T22:12:43Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![oldbug](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/o/c0e974/32.png) [@oldbug](https://www.ruby-forum.com/u/oldbug)\
**Post date:** [March 18, 2008, 10:12pm UTC](https://www.ruby-forum.com/t/how-does-form-for-work/132297/1 "2008-03-18T22:12:43Z")

</div>

I was just reading the documentation for “form\_for” and I noticed that  
it said: “Worth noting is that the form\_for tag is called in a ERb  
evaluation block, not an ERb output block.”

Being a curious sort of guy, I wonder how this works…  
If it’s not in an output block, how does the appropriate markup get  
rendered?  
If I wanted to figure this out myself, where would I look?

–wpd

---

<div class="post-metadata">

**Author:** ![oldbug](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/o/c0e974/32.png) [@oldbug](https://www.ruby-forum.com/u/oldbug)\
**Post date:** [March 18, 2008, 10:20pm UTC](https://www.ruby-forum.com/t/how-does-form-for-work/132297/2 "2008-03-18T22:20:22Z")

</div>

> **[ActionView::Helpers::FormHelper](https://api.rubyonrails.org/classes/ActionView/Helpers/FormHelper.html#M000920)**
>
> Form helpers are designed to make working with resources much easier compared to using vanilla HTML.

The reason it says that is because contrary to what would seem  
“normal” in rails at first glance, since the form\_for tag outputs  
Markup, you would put \<%= %\> around it. Since it’s an Block however,  
it’s just \<% %\> with a closing \<% end %\>

That’s all the note is making you aware of.

---

<div class="post-metadata">

**Author:** ![oldbug](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/o/c0e974/32.png) [@oldbug](https://www.ruby-forum.com/u/oldbug)\
**Post date:** [March 19, 2008, 1:09am UTC](https://www.ruby-forum.com/t/how-does-form-for-work/132297/3 "2008-03-19T01:09:52Z")

</div>

On Tue, Mar 18, 2008 at 5:19 PM, sw0rdfish [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> [ActionView::Helpers::FormHelper](http://api.rubyonrails.org/classes/ActionView/Helpers/FormHelper.html#M000920)
> 
> The reason it says that is because contrary to what would seem  
> “normal” in rails at first glance, since the form\_for tag outputs  
> Markup, you would put \<%= %\> around it. Since it’s an Block however,  
> it’s just \<% %\> with a closing \<% end %\>
> 
> That’s all the note is making you aware of.

Yes, I understood the note. I’m just curious… How does form\_for _do_  
that?

–wpd

---

<div class="post-metadata">

**Author:** ![oldbug](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/o/c0e974/32.png) [@oldbug](https://www.ruby-forum.com/u/oldbug)\
**Post date:** [March 19, 2008, 1:47am UTC](https://www.ruby-forum.com/t/how-does-form-for-work/132297/4 "2008-03-19T01:47:59Z")

</div>

Oh, now I see it…  
form\_for calls concat(sometext, binding) which is the equivalent,  
through some sort of Ruby/ERb magic to \<%= sometext %\>.

OK, curiosity bump satisfied… now back to my regularly scheduled  
program.

–wpd
