Form_tag code block

I have this in a template->

Hello
<% form_tag :action => “create” do %>
My pretty form!
<% end %>

And all I’m getting at output is ->

Hello

Actually, any actionview helper that is supposed to take a code block
is not working for me. What wicked stupid thing am I missing here?

Hello
<% form_tag :action => “create” do %>
My pretty form!
<% end %>

you need to use <%= on the form tag even if you use the block method

Thanks for the reply!

Sadly, though, I tried that.

Error->

compile error
C:/INSTAN~1/rails_apps/lumina_erp/config/…/app/views/bom_lines/
edit.rhtml:2: parse error, unexpected ‘)’
_erbout.concat(( form_tag :action => “create” do ).to_s);
_erbout.concat “\n”
^
C:/INSTAN~1/rails_apps/lumina_erp/config/…/app/views/bom_lines/
edit.rhtml:5: parse error, unexpected kEND, expecting ‘)’

Obvioulsy from the error message you can see that this is on a M$
machine (InstantRails 1.4 WinXP).

Anyways, just tried it on Ubuntu server and it works fine. Must be a
problem with InstantRails.

So to recap… The first way I posted (and that’s all over
api.rubyonrails.org) is correct. I’m gonna try and update activeview
through gem now I guess.

Thanks for your help!

On Feb 16, 4:20 pm, Keynan P. [email protected]

julian wrote:

I have this in a template->

Hello
<% form_tag :action => “create” do %>
My pretty form!
<% end %>

And all I’m getting at output is ->

Hello

Actually, any actionview helper that is supposed to take a code block
is not working for me. What wicked stupid thing am I missing here?

This format require rails 1.2. If you are on 1.1.6 you have to use:

<%= form_tag :action => ‘create’ %>
Form!
<%= end_form_tag %>

And you can never use blocks with <%= %> with ERb because of the way ERb
is evaluated within the blocks.

This will always yield an error. What does <%= end %> output in this
context?

<%= foo do %>
<%= ‘foo’ %>
<%= end %>

Only way to do this is:

<% foo do %>
<%= ‘foo’ %>
<% end %>

But if you want to do form tags with blocks you use 1.2.

Have you tried adding form fields to the form tag? i.e.

Hello
<% form_tag :action => “create” do %>

My pretty form!

<%= text_field "foo", "bar" %>

<%= submit_tag "Do it!" %>

<% end %>

Also when you said it only outputted Hello was that what you saw
rendered in the browser or was that the source of the output?

Niels