[Rails] Re: rekord id-je .create után
Gábor Sebestyén
segabor at gmail.com
Tue Feb 21 17:25:56 GMT 2006
> Hali!
>
> Mi a legegyszerűbb módja annak, hogy egy pl. note = Notes.create(...)
> után megkapjam az adott note ActiveRecord id-ját (primary key)? Sajnos
> ez ugye 0, mivel frissen lett létrehozva...
Sorry, missed the proper mailing list :)
So how can I determine a newly created record's primary key (id) after
issuing create method? Consider I have the following: note =
Notes.create(...). It will create a Notes record but note.id will be
zero instead of having valid primary key.
I know this is normal in term of RoR but is there an easy way to
retrieve the id of this object? Do I have to find the record again to
have its primary key?
Thanks,
Gábor
More information about the Rails
mailing list