Help passing attributes

I know this is a really basic and simple thing for Rails, but as a newbie, I am having trouble figuring it out . . .

I have a home page with a register link which executes the register action and shows the first (of two) registration page. When I click the "Continue" button, I want to go to the "continue_registration" action which will take the data from the first form and create the user object. That part works as planned. However, the second form has all the optional fields (home address, phone, etc.). The questionI have is how do I pass the user id (or the user model) from the register action to the continue_registration action?

I have a form on the second page using this code:    <form id="registerForm2" method="post" action="completeRegistration">

But in the completeRegistration action, the params hash does not have any reference to my user id.

Can someone help with this?

Thank you

Ok, so in action continue_registraton you have this user_id It should be part of the second form, so it is handed over to the third one. Commonly that's done with a hidden field in the second form:

(assuming, it's in params[:user_id]) <%= f.hidden_field :user_id, :value => params[:user_id] %>

just replace params[:user_id] with the variable holding it, if it's not in params hash

I was trying something like that. My first form starts with:

     <form id="registerForm" method="post" action="register02">             <input type="hidden" name="passedUser" id="passedUser" value="<% @user.id %>" >              . . .

In my controller, I do this:

  def register     @user = User.create()   end

But when I inspect (using NetBeans debugger) the params hash, passedUser is an empty string. I was expecting the User ID (42, or whatever number is assigned by the database)

What am I missing?

You can put the user_id in Rails flash which will remember it for only the next request and then automatically discard it. Your next request is the "continue_registration" so you can do whatever you want with it. As a matter of fact, you can pretty much put all the user data from the first form in it so that you have access to it in the second form. Flash only remembers the data stored in it for the next request and then is automatically cleared by rails. I would not put it in session since you will have to manually clean it. Bharat