get last insert id when using Activerecord
Posted
by pierr
on Stack Overflow
See other posts from Stack Overflow
or by pierr
Published on 2010-05-28T07:15:16Z
Indexed on
2010/05/28
7:22 UTC
Read the original article
Hit count: 264
Hi,
For Sqilte3 C API, I would use sqlite3_last_insert_rowid
. How to get this id when using ActiveRecord after insert a new record? I use following way to insert a new record :
Section.new |s|
s.a = 1
s.b = 2
#I expected the return value of save to be the last_insert_id, but it is NOT
s.save
end
© Stack Overflow or respective owner