Retrieve previous id

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?

On 5/9/06, ss [email protected] 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

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

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs