How does form_for work?

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

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.

On Tue, Mar 18, 2008 at 5:19 PM, sw0rdfish [email protected] wrote:

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

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

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs