# Passing id in multi part form

**URL:** <https://www.ruby-forum.com/t/passing-id-in-multi-part-form/134814>\
**Category:** Rails\
**Created:** [April 15, 2008, 12:15pm UTC](https://www.ruby-forum.com/t/passing-id-in-multi-part-form/134814 "2008-04-15T12:15:15Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![lfeistel](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/l/ecc23a/32.png) [@lfeistel](https://www.ruby-forum.com/u/lfeistel)\
**Post date:** [April 15, 2008, 12:15pm UTC](https://www.ruby-forum.com/t/passing-id-in-multi-part-form/134814/1 "2008-04-15T12:15:15Z")

</div>

Hi Guys,

I’m building an application that allows users to first fill in details  
of a recent trip to the gym, once they click submit these details are  
saved to a database table and redirects to a form that lets them input  
the exercises they carried out and saves them in a second table.

I need to know how to pass the id of the update to the second form, my  
controller for the update currently looks like this:

def update  
@update = Update.find(params[:id])  
if @update.update\_attributes(params[:update])  
flash[:notice] = ‘Update was successfully updated.’  
redirect\_to :action =\> ‘show’, :id =\> @update  
else  
render :action =\> ‘edit’  
end  
end

the redirect works fine, I’m pretty certain the :id=\> is completely  
wrong but I’m not sure how to go about this…

cheers,  
Lee.

---

<div class="post-metadata">

**Author:** ![lfeistel](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/l/ecc23a/32.png) [@lfeistel](https://www.ruby-forum.com/u/lfeistel)\
**Post date:** [April 15, 2008, 5:24pm UTC](https://www.ruby-forum.com/t/passing-id-in-multi-part-form/134814/2 "2008-04-15T17:24:10Z")

</div>

Lee, try:

redirect\_to :action =\> ‘show’, :id =\> @update.id

or, since it’s still on the params:

redirect\_to :action =\> ‘show’, :id =\> params[:id]

Or, if you are using RESTful routes, you can just do:

redirect\_to @update

And that will default to the show action with the @update’s ID.

Another thing to remember: if you need to pass data back and forth  
between requests, that’s one of the things the session hash is good  
for:

Action #1:  
session[:foo] = “bar”

Action #2:

foo = session[:foo] # =\> foo = “bar”

HTH!

-Danimal

On Apr 15, 4:15 am, Lee F. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)
