Hi all,
I''ve got a model - Images - and when I insert a new image into that
db,table I would like to grab hold of the last insertion id of that
row/record and then process it further and save reworked version back
into the db.table again.
Example: a new image gets inserted as a db.table.row with ID =
12345678 (id = primary key)
The ID (12345678) is then retrieved and processed and inserted as
''human_ref'' where it''s styled as 1234-5678 in the
same db.table.row.
Any ideas of how to do this in Rails ? I guess I can use the
''after_save'' callback inside the model - Image - to do the
processing, but how could I get hold of the last insertion id
easily ? IF AR is currently not able to present this last insertion
id easily, could a ''AR.last_insertion_id'' method be created
and added
to Ralls ?
Else I guess I would have to load the Image object again with a
select sql and then retrieve the id, but that seem expensive and a
bit complicated. I plan to insert big batches of images in this way,
ie: 100+ images in one go, so not having to execute a bundle of
queries repeatedly would be great from many different angles.
Any advice/guidance would be very much appreciated.
Kind regards,
Mats
----
"TextMate, coding with an incredible sense of joy and ease"
- www.macromates.com -