This seems like something that should be trivial, but I'm not
satisfied with any of the solutions I've tried.
I want to read an Active Record model into two identical memory
objects, allowing the user to edit one of them. Then when it comes
time to write, I'll compare the two objects' data, only updating the
DB if there's been a change.
The easiest way to deep-copy DB models is to simply find() them
twice, but that's just wrong. Serializing the object with Marshal
would work for copying, but it's unsatisfying, and comparing two
serializations seems as though it would cause false negatives. I
could roll my own recursive copy and compare methods, and attaching
them to ActiveRecord::Base or to Object, but this is probably
something that's already been done better by someone else.
Any ideas on a hassle-free way to do a deep copy and deep compare on
two model objects?