Skip to content

Commit

Permalink
Fix get version data with full name of class
Browse files Browse the repository at this point in the history
  • Loading branch information
chimame committed Sep 20, 2017
1 parent ac96b70 commit 5c1c543
Show file tree
Hide file tree
Showing 4 changed files with 4 additions and 4 deletions.
2 changes: 1 addition & 1 deletion lib/paper_trail/reifiers/belongs_to.rb
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ def load_record(assoc, id, options, version)
# @api private
def load_version(assoc, id, transaction_id, version_at)
assoc.klass.paper_trail.version_class.
where("item_type = ?", assoc.class_name).
where("item_type = ?", assoc.klass.name).
where("item_id = ?", id).
where("created_at >= ? OR transaction_id = ?", version_at, transaction_id).
order("id").limit(1).first
Expand Down
2 changes: 1 addition & 1 deletion lib/paper_trail/reifiers/has_many.rb
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ def load_versions_for_hm_association(assoc, model, version_table, tx_id, version
select("MIN(version_id)").
where("foreign_key_name = ?", assoc.foreign_key).
where("foreign_key_id = ?", model.id).
where("#{version_table}.item_type = ?", assoc.class_name).
where("#{version_table}.item_type = ?", assoc.klass.name).
where("created_at >= ? OR transaction_id = ?", version_at, tx_id).
group("item_id").
to_sql
Expand Down
2 changes: 1 addition & 1 deletion lib/paper_trail/reifiers/has_many_through.rb
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ def collection_through_belongs_to(through_collection, assoc, options, tx_id)
def load_versions_for_hmt_association(assoc, ids, tx_id, version_at)
version_id_subquery = assoc.klass.paper_trail.version_class.
select("MIN(id)").
where("item_type = ?", assoc.class_name).
where("item_type = ?", assoc.klass.name).
where("item_id IN (?)", ids).
where(
"created_at >= ? OR transaction_id = ?",
Expand Down
2 changes: 1 addition & 1 deletion lib/paper_trail/reifiers/has_one.rb
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ def load_version_for_has_one(assoc, model, transaction_id, version_at)
model.class.paper_trail.version_class.joins(:version_associations).
where("version_associations.foreign_key_name = ?", assoc.foreign_key).
where("version_associations.foreign_key_id = ?", model.id).
where("#{version_table_name}.item_type = ?", assoc.class_name).
where("#{version_table_name}.item_type = ?", assoc.klass.name).
where("created_at >= ? OR transaction_id = ?", version_at, transaction_id).
order("#{version_table_name}.id ASC").
first
Expand Down

0 comments on commit 5c1c543

Please sign in to comment.