I have a form being submitted for a complex model including many associations. I need to save 2 copies of the object. One that will not be touched and is used only as a reference for what was originally submitted, the other will be edited by my users.
I originally preformed a deep clone of the object and all associations, and then saved both to the database, marking a field for which was the original, and which can be edited. This is becoming too complex however and I would like a simpler solution
I was thinking my best bet would be to serialize the entire object and store it in a single field within the editable object. So my question is: Is it possible to serialize an object, including associations, and store it in a single field?
Should I do this at the model level? or should I just save what was returned from the form in a single field? (ie. application.original_form = params[:application]).
Thanks for your help!
Ryan
EDIT —
I am attempting this approach:
https://gist.github.com/1298567
I am saving the returned parameters in a serialize field.
Does anyone see any downfall with this? It seems like the simplest approach.
Thanks again!
Ryan
I’ve gone with this approach:
To me this seems like the simplest approach to the issue.