Retrieve previous id


#1

Hi,

I have this piece of code,

if @quote.save
flash[:notice] = ‘Quote was successfully created.’

  #return id of preiously inserted quote

  #enter this id in the correct related project field

  redirect_to :action => 'list'

end

How can I return the id of the saved data?


#2

On 5/9/06, ss removed_email_address@domain.invalid wrote:

How can I return the id of the saved data?

@quote.id, or just @quote, should return a value once the record’s been
saved.

-Isak


#3

ss wrote:

Hi,

I have this piece of code,

if @quote.save
flash[:notice] = ‘Quote was successfully created.’

  #return id of preiously inserted quote

  #enter this id in the correct related project field

  redirect_to :action => 'list'

end

How can I return the id of the saved data?

yes, you can use @quote.id after being saved, before being saved you can
not use @quote.id