Ruby on Rails
HowToImplementADeepCopy

I’m working on a “Test Database” project, and to save work, I’d like to be able to implement a deep copy. For an individual Test, I have a “Clone” capability, but that’s shallow, and only copies the Test data from the cloned Test into a new Test and throws the user to the edit form with that new Test (so they can replace my default “Clone of X” name, and alter the details before saving.

With a deep copy, I’d also like to be able to copy the list of associated Processes from the source Test to the clone Test, but at the time of cloning in the Test controller, I don’t yet have an ID for the new clone.

The Processes live in their own table, and there’s a join table in the middle (typical many-to-many).

Any ideas? And thanks in advance.