moiristo / deep_cloneable

This gem gives every ActiveRecord::Base object the possibility to do a deep clone that includes user specified associations.
MIT License
785 stars 89 forks source link

Would it be relevant to include dup in a transaction? #105

Closed fchampreux closed 5 years ago

fchampreux commented 5 years ago

Hi, I am planning to use deep_clonable to manage versions of business rules. As I work in an international environment, Business rules are translated, so that when creating a new version, all children translations must follow. A new version should not be created if all associated translations cannot be duplicated as well. That's why I am thinking of ActiveRecord transactions. Do you think this is feasible?

moiristo commented 5 years ago

Hello, thanks for your question!

deep_cloneable doesn't save records; it generates a structure of duped records. How the record is saved is then up to you. I'd say that saving the duped record (and its associations) should already take place in a transaction, so I guess it's only needed to wrap everything in a transaction if you need to save multiple versions of those business rules at once.