lib/paper_trail/reifier.rb
# Restore the `model`'s has_many associations not associated through
# another association.
Restore the `model`'s has_many associations not associated through
another association.
Restore the ` model ` ' s has_many associations not associated through another association .
def reify_has_many_directly(transaction_id, associations, model, options = {})
        version_table_name = model.class.paper_trail.version_class.table_name
        each_enabled_association(associations) do |assoc|
          version_id_subquery = PaperTrail::VersionAssociation.
            joins(model.class.version_association_name).
            select("MIN(version_id)").
            where("foreign_key_name = ?", assoc.foreign_key).
            where("foreign_key_id = ?", model.id).
            where("#{version_table_name}.item_type = ?", assoc.class_name).
            where("created_at >= ? OR transaction_id = ?", options[:version_at], transaction_id).
            group("item_id").
            to_sql
          versions = versions_by_id(model.class, version_id_subquery)
          collection = Array.new model.send(assoc.name).reload 
          prepare_array_for_has_many(collection, options, versions)
          model.send(assoc.name).proxy_association.target = collection
        end
      end
def reify_has_many_directly ( transaction_id , associations , model , options = { } ) version_table_name = model . class . paper_trail . version_class . table_name each_enabled_association ( associations ) do | assoc | version_id_subquery = PaperTrail :: VersionAssociation . joins ( model . class . version_association_name ) . select ( "MIN(version_id)" ) . where ( "foreign_key_name = ?" , assoc . foreign_key ) . where ( "foreign_key_id = ?" , model . id ) . where ( "#{version_table_name}.item_type = ?" , assoc . class_name ) . where ( "created_at >= ? OR transaction_id = ?" , options [ :version_at ] , transaction_id ) . group ( "item_id" ) . to_sql versions = versions_by_id ( model . class , version_id_subquery ) collection = Array . new model . send ( assoc . name ) . reload prepare_array_for_has_many ( collection , options , versions ) model . send ( assoc . name ) . proxy_association . target = collection end end
Restore the `model`'s has_many associations not associated through
another association.
Restore the ` model ` ' s has_many associations not associated through another association .
# to avoid cache
transaction_id
<not_specific>
associations
<not_specific>
model
<not_specific>
options
<not_specific>