lib/paper_trail/reifier.rb
# See `VersionConcern#reify` for documentation.
# @api private
See `VersionConcern#reify` for documentation.
See ` VersionConcern#reify ` for documentation .
def reify_belongs_tos(transaction_id, model, options = {})
        associations = model.class.reflect_on_all_associations(:belongs_to)
        each_enabled_association(associations) do |assoc|
          collection_key = model.send(assoc.association_foreign_key)
          version = assoc.klass.paper_trail.version_class.
            where("item_type = ?", assoc.class_name).
            where("item_id = ?", collection_key).
            where("created_at >= ? OR transaction_id = ?", options[:version_at], transaction_id).
            order("id").limit(1).first
          collection = if version.nil?
                         assoc.klass.where(assoc.klass.primary_key => collection_key).first
                       else
                         version.reify(
                           options.merge(
                             has_many: false,
                             has_one: false,
                             belongs_to: false,
                             has_and_belongs_to_many: false
                           )
                         )
                       end
          model.send("#{assoc.name}=".to_sym, collection)
        end
      end
def reify_belongs_tos ( transaction_id , model , options = { } ) associations = model . class . reflect_on_all_associations ( :belongs_to ) each_enabled_association ( associations ) do | assoc | collection_key = model . send ( assoc . association_foreign_key ) version = assoc . klass . paper_trail . version_class . where ( "item_type = ?" , assoc . class_name ) . where ( "item_id = ?" , collection_key ) . where ( "created_at >= ? OR transaction_id = ?" , options [ :version_at ] , transaction_id ) . order ( "id" ) . limit ( 1 ) . first collection = if version . nil? assoc . klass . where ( assoc . klass . primary_key => collection_key ) . first else version . reify ( options . merge ( has_many : false , has_one : false , belongs_to : false , has_and_belongs_to_many : false ) ) end model . send ( "#{assoc.name}=" . to_sym , collection ) end end
See `VersionConcern#reify` for documentation.
See ` VersionConcern#reify ` for documentation .
transaction_id
<not_specific>
model
<not_specific>
options
<not_specific>
api
None