# Form tag multipart

**URL:** <https://www.ruby-forum.com/t/form-tag-multipart/133530>\
**Category:** Rails\
**Created:** [April 1, 2008, 11:06am UTC](https://www.ruby-forum.com/t/form-tag-multipart/133530 "2008-04-01T11:06:46Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![qwerty73](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/q/9d8465/32.png) [@qwerty73](https://www.ruby-forum.com/u/qwerty73)\
**Post date:** [April 1, 2008, 11:06am UTC](https://www.ruby-forum.com/t/form-tag-multipart/133530/1 "2008-04-01T11:06:46Z")

</div>

Hi to all,

i’m trying to pass the id of my record within the multipart form.  
I’ve tried to pass it like this but it gives a compile error…

\<%= form\_tag( { :action =\> ‘create’, :id =\> @nominee }, :multipart =\>  
true ) do -%\>  
\<%= render :partial =\> ‘form’ %\>  
\<%= submit\_tag ‘Edit’ %\>  
\<% end %\>

\<%= link\_to ‘Show’, :action =\> ‘show’, :id =\> @nominee %\> |  
\<%= link\_to ‘Back’, :action =\> ‘list’ %\>

Can anybody help me???

Thanks i advance

Andrea

---

<div class="post-metadata">

**Author:** ![qwerty73](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/q/9d8465/32.png) [@qwerty73](https://www.ruby-forum.com/u/qwerty73)\
**Post date:** [April 1, 2008, 5:31pm UTC](https://www.ruby-forum.com/t/form-tag-multipart/133530/2 "2008-04-01T17:31:32Z")

</div>

You typically won’t pass an id to a create action. I’m doing this  
with an update action using the same syntax that you have, and it  
works fine. If it matters, I don’t have an equal sign next to my  
form\_tag (i.e., \<% form\_tag…, not \<%= form\_tag…).

Do you want to set the id of the record that you’re creating (not  
recommended), or are you trying to pass a value to the record like  
nominee\_id = 12?

If you’re still having problems, please paste the error.

-Kyle

On Apr 1, 4:06 am, Andrea C. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)

---

<div class="post-metadata">

**Author:** ![qwerty73](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/q/9d8465/32.png) [@qwerty73](https://www.ruby-forum.com/u/qwerty73)\
**Post date:** [April 3, 2008, 9:32am UTC](https://www.ruby-forum.com/t/form-tag-multipart/133530/3 "2008-04-03T09:32:45Z")

</div>

You’ll need

\<%= form\_tag( { :action =\> ‘update’, :id =\> @nominee }, {:multipart =\>  
true} ) do -%\>

While Ruby will attempt to do “THE RIGHT THING”, you’ll find that if  
you specify the hash curly-braces on the first hash, you’ll also need  
to specify them on the second hash.

Julian.

Learn Ruby on Rails! CHECK OUT THE FREE VIDS (LIMITED TIME) NEW VIDEO  
(#2) OUT NOW!  
[http://sensei.zenunit.com/](http://sensei.zenunit.com/)

---

<div class="post-metadata">

**Author:** ![qwerty73](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/q/9d8465/32.png) [@qwerty73](https://www.ruby-forum.com/u/qwerty73)\
**Post date:** [April 3, 2008, 9:50am UTC](https://www.ruby-forum.com/t/form-tag-multipart/133530/4 "2008-04-03T09:50:17Z")

</div>

> While Ruby will attempt to do “THE RIGHT THING”, you’ll find that if  
> you specify the hash curly-braces on the first hash, you’ll also need  
> to specify them on the second hash.

Hi Julian,

i still have an error, the code is:

# Editing nominee

\<%= form\_tag( { :action =\> ‘update’, :id =\> @nominee }, {:multipart =\>  
true} do) -%\>  
\<%= render :partial =\> ‘form’ %\>  
\<%= submit\_tag ‘Edit’ %\>  
\<% end %\>

and the compile error:

compile error  
script/…/config/…/app/views/nominees/edit.rhtml:4: syntax error,  
unexpected kDO, expecting ‘)’  
\_erbout.concat(( form\_tag( { :action =\> ‘update’, :id =\> @nominee },  
{:multipart =\> true} do) ).to\_s)  
^  
script/…/config/…/app/views/nominees/edit.rhtml:5: syntax error,  
unexpected tIDENTIFIER, expecting ‘)’  
\_erbout.concat " "; \_erbout.concat(( render :partial =\> ‘form’ ).to\_s);  
\_erbout.concat “\n”  
^  
script/…/config/…/app/views/nominees/edit.rhtml:12: syntax error,  
unexpected kEND, expecting $end

what could it be?

---

<div class="post-metadata">

**Author:** ![qwerty73](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/q/9d8465/32.png) [@qwerty73](https://www.ruby-forum.com/u/qwerty73)\
**Post date:** [April 3, 2008, 9:57am UTC](https://www.ruby-forum.com/t/form-tag-multipart/133530/5 "2008-04-03T09:57:36Z")

</div>

do has to come after the close parenthesis… do reprsents the start  
of a block, and comes after the other arguments, which go inside the  
parenthesis.

\<%= form\_tag( { :action =\> ‘update’, :id =\> @nominee }, {:multipart =\>  
true}) do -%\>  
\<%= render :partial =\> ‘form’ %\>  
\<%= submit\_tag ‘Edit’ %\>  
\<% end %\>

---

<div class="post-metadata">

**Author:** ![qwerty73](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/q/9d8465/32.png) [@qwerty73](https://www.ruby-forum.com/u/qwerty73)\
**Post date:** [April 3, 2008, 9:23am UTC](https://www.ruby-forum.com/t/form-tag-multipart/133530/6 "2008-04-03T09:23:52Z")

</div>

Hi Kyle,

sorry 🙂 i want to pass it to the update function not the create, but i  
still have this error:

compile error  
script/…/config/…/app/views/nominees/edit.rhtml:4: syntax error,  
unexpected ‘)’  
\_erbout.concat(( form\_tag( { :action =\> ‘update’, :id =\> @nominee },  
:multipart =\> true ) do ).to\_s)

Code

\<%= form\_tag( { :action =\> ‘update’, :id =\> @nominee }, :multipart =\>  
true ) do -%\>  
\<%= render :partial =\> ‘form’ %\>  
\<%= submit\_tag ‘Edit’ %\>  
\<% end %\>

thanks for your help!!

> works fine. If it matters, I don’t have an equal sign next to my  
> form\_tag (i.e., \<% form\_tag…, not \<%= form\_tag…).
> 
> Do you want to set the id of the record that you’re creating (not  
> recommended), or are you trying to pass a value to the record like  
> nominee\_id = 12?
> 
> If you’re still having problems, please paste the error.
> 
> -Kyle
> 
> On Apr 1, 4:06 am, Andrea C. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)

---

<div class="post-metadata">

**Author:** ![qwerty73](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/q/9d8465/32.png) [@qwerty73](https://www.ruby-forum.com/u/qwerty73)\
**Post date:** [April 3, 2008, 10:03am UTC](https://www.ruby-forum.com/t/form-tag-multipart/133530/7 "2008-04-03T10:03:23Z")

</div>

Julian 🙂 it doesn’t work even like this…

\<%= form\_tag( { :action =\> ‘update’, :id =\> @nominee }, {:multipart =\>  
true}) do -%\>  
\<%= render :partial =\> ‘form’ %\>  
\<%= submit\_tag ‘Edit’ %\>  
\<% end %\>

the compile error:

compile error  
script/…/config/…/app/views/nominees/edit.rhtml:4: syntax error,  
unexpected ‘)’  
\_erbout.concat(( form\_tag( { :action =\> ‘update’, :id =\> @nominee },  
{:multipart =\> true}) do ).to\_s)  
^  
script/…/config/…/app/views/nominees/edit.rhtml:14: syntax error,  
unexpected kEND, expecting ‘)’

??

Really thanks for your help!

---

<div class="post-metadata">

**Author:** ![qwerty73](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/q/9d8465/32.png) [@qwerty73](https://www.ruby-forum.com/u/qwerty73)\
**Post date:** [April 3, 2008, 10:29am UTC](https://www.ruby-forum.com/t/form-tag-multipart/133530/8 "2008-04-03T10:29:09Z")

</div>

IT works!!!

Really thanks!!!

---

<div class="post-metadata">

**Author:** ![qwerty73](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/q/9d8465/32.png) [@qwerty73](https://www.ruby-forum.com/u/qwerty73)\
**Post date:** [April 3, 2008, 10:07am UTC](https://www.ruby-forum.com/t/form-tag-multipart/133530/9 "2008-04-03T10:07:37Z")

</div>

You shouldn’t use \<%= %\> when you’re using the block form.

Julian.

Learn Ruby on Rails! CHECK OUT THE FREE VIDS (LIMITED TIME) NEW VIDEO  
(#2) OUT NOW!  
[http://sensei.zenunit.com/](http://sensei.zenunit.com/)
