Topic: Save ID ask reference in same form

Hi there,

I have just made a form where a user kan add all it's user information. This is called client, besided this the new user must enter e loginname and a password. THis is no problem and both data is being saved in the tables, but i need to save the id of the client as a reference id to the logins table. Because in the create method in the client_controler the @client.save and the @login.save is being used i need to have a small pose to get the just saved client id as a reference id to the login.save.

My question is how i do this in rails

hopefully someone can help me shine some bright lights on this problem,

Greets

Vincent

Re: Save ID ask reference in same form

Rails automatically assigns the id to the instance after it is saved. For example:

@client = Client.new
@client.id # => nil
@client.save
@client.id # => 1

Railscasts - Free Ruby on Rails Screencasts