def save_habtm_associations(version)
      @record.class.reflect_on_all_associations(:has_and_belongs_to_many).each do |a|
        next unless save_habtm_association?(a)
        habtm_assoc_ids(a).each do |id|
          ::PaperTrail::VersionAssociation.create(
            version_id: version.transaction_id,
            foreign_key_name: a.name,
            foreign_key_id: id,
            foreign_type: a.klass
          )
        end
      end
    end
def save_habtm_associations(version)
      @record.class.reflect_on_all_associations(:has_and_belongs_to_many).each do |a|
        next unless save_habtm_association?(a)
        habtm_assoc_ids(a).each do |id|
          ::PaperTrail::VersionAssociation.create(
            version_id: version.transaction_id,
            foreign_key_name: a.name,
            foreign_key_id: id,
            foreign_type: a.klass
          )
        end
      end
    end
When a record is created, updated, or destroyed, we determine what the
 HABTM associations looked like before any changes were made, by using
 the `paper_trail_habtm` data structure. Then, we create
 `VersionAssociation` records for each of the associated records.
 @api private