I have an ActiveRecord object that I need to be able to uniquely
identify before I actually save the object (I may not end up saving
the object based on conditions). This is because I want to use the ID
in another context (a file name in the filesystem).
Depending on conditions, I may or may not need to do a lot of stuff
between the time that I generate the object ID and actually make the
decision to save the object. I am toying with the idea of using an ID
generator for this object.
I wanted to get some input on using an “external to the DB” generator to
create my unique ids for insertion into the DB.
Am I overthinking this? Should I just do the insert as soon as possible
to have the DB generate my ID, use the ID as I need to, and then either
delete that record (or rollback a transaction) later if it turns out
that the record shouldn’t be saved after all?
Hope this makes sense.