moiristo / deep_cloneable

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

Can't clone just an association without explicitly excluding all parent attributes #72

Closed psyopcop closed 8 years ago

psyopcop commented 8 years ago

It would be nice to be able to clone only an association while excluding all parent attributes like so:

pirate.deep_clone only: :treasures

Obviously, this can be done by including the association and then explicitly excluding the parent attributes:

pirate.deep_clone include: :treasures, except: Pirate.column_names

but I expected only to work properly for this.

moiristo commented 8 years ago

:only is the inverse of :except, it's not meant for specifying inclusions. This would do the same, I guess:

pirate.deep_clone only: [], include: :treasures
psyopcop commented 8 years ago

That works. Closing.