diff --git a/README.md b/README.md index f4dcbb2..0300eb0 100644 --- a/README.md +++ b/README.md @@ -122,13 +122,12 @@ t.location.latitude # 12.345, instead of 54.321 When calling `changeset` on a `version` you can include changes to associations by specifying the following options -- To restore Has-Many associations, use option `has_many: true` - To restore Has-Many-Through associations, use option `has_many_through: true` For example: ```ruby -item.versions.last.changeset(has_many: false, has_many_through: true) +item.versions.last.changeset(has_many_through: true) ``` # Limitations diff --git a/lib/paper_trail_association_tracking/version_concern.rb b/lib/paper_trail_association_tracking/version_concern.rb index af07e1e..65b83c0 100644 --- a/lib/paper_trail_association_tracking/version_concern.rb +++ b/lib/paper_trail_association_tracking/version_concern.rb @@ -39,25 +39,12 @@ def changeset(options = {}) super() return @changeset unless ::PaperTrail.config.track_associations? - @changeset = load_changeset_has_many(@changeset) if options[:has_many] @changeset = load_changeset_has_many_through(@changeset) if options[:has_many_through] @changeset end private - def load_changeset_has_many(changes) - has_many_assocs - .reduce(changes) do |acc, assoc| - assoc_changes = has_many_changes(assoc) - acc.merge!(assoc_changes) if assoc_changes.any? - - acc - end - - changes - end - def load_changeset_has_many_through(changes) has_many_through_assocs .reduce(changes) do |acc, assoc|