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 Farrar
<rails-mailing-l...-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org>
wrote:> 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.
> --
> Posted viahttp://www.ruby-forum.com/.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Ruby on Rails: Talk" group.
To post to this group, send email to
rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
To unsubscribe from this group, send email to
rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---