Has_many before saving record

I am currently creating a small app that can be simplified as follows:

An Album that has_many AlbumTracks
An AlbumTrack that belongs_to an Album

The user will create a new album - that is - not currently saved in
the database.
They will then add tracks to the album with an inline form that will
update the existing display, appending the track to the list of

It is important that the Album record has not yet been saved for
usability purposes, as the user may decide to abort the creation,
which could be as simple as closing their browser, and incomplete
albums should not be stored in the database.

Additionally, during track insertion, the user must be able to reorder
the tracks, using the sortable_element scriptaculous helper. Again
before the saving of the record.

My thoughts on implementing this have been to use a session array to
store the track listings in, and then copying this tracklist array to
the main Album object on save/update. Is this the best way to achieve

I am aware that I could simply use an html text_field array, which
would be fine for the initial insertion of the content, but could
potentially cause problems on an edit, whereby certain Tracks may have
been allocated an ID in the database from a previous save, and new
Tracks will not have an allocated ID.

Does anyone have any thoughts on this, or better still - a
solution! :slight_smile:

Kind Regards,


p.s. the actual webapp is not an album and tracklist project, but that
is probably the simplest way I can describe my requirement - please
dont point me to the album/tracklist howto, as its not relevant!