I’m writing a feature in my application which is used to clone a whole load of activerecord models and their hierachy. So that I accidentaly don’t change the original records I am using the #readonly feature on relations, which is great.
I am using the #clone method to copy those original objects, but there seems to be no way to remove the readonly status on the cloned objects which means I can’t save the new objects I have created.
If I load the original objects without using #readonly then it works fine, but then I run the risk of the original records accidentally being deleted.
How can I remove the readonly status?
Use instance_variable_set?
I’m not sure if there’s a cleaner way though!