paper_trail-association_tracking 2.3.0 → 2.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/CHANGELOG.md +6 -1
- data/README.md +1 -1
- data/lib/generators/paper_trail_association_tracking/templates/add_transaction_id_column_to_versions.rb.erb +1 -1
- data/lib/paper_trail-association_tracking.rb +6 -6
- data/lib/paper_trail_association_tracking/frameworks/active_record.rb +2 -0
- data/lib/paper_trail_association_tracking/frameworks/rails/railtie.rb +1 -4
- data/lib/paper_trail_association_tracking/record_trail.rb +18 -3
- data/lib/paper_trail_association_tracking/version.rb +1 -1
- data/lib/paper_trail_association_tracking/version_concern.rb +2 -0
- metadata +3 -7
- data/lib/paper_trail_association_tracking/frameworks/rails.rb +0 -3
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 53355e19e486ebed17b18112e6f20a118b98dc5a3777ba8fd2bb5dfd42864be3
|
|
4
|
+
data.tar.gz: 3aa942c6ab92e50d27bcaf8092153d3fb997922cb9a4266cbe372e0433e0be0f
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 198d8abfe3e63c3d73b850fce97c5ffaf8291b7e8bb99385301e03585e064e0c9a61781b421219beaefd1d4d2f925deb0b0690a42a0f7065347531c5bf5c59b4
|
|
7
|
+
data.tar.gz: 60045bcaccabb01aae1567187d4978cd0fd84f3cc354fa06bc60630d5809850e33b5107533c8482ea69af1bbdd4d3ad54bfa6805b04d27588754dfdbc4bf1b2a
|
data/CHANGELOG.md
CHANGED
|
@@ -1,8 +1,13 @@
|
|
|
1
1
|
# CHANGELOG
|
|
2
2
|
|
|
3
|
-
### Unreleased - [View Diff](https://github.com/westonganger/paper_trail-association_tracking/compare/v2.
|
|
3
|
+
### Unreleased - [View Diff](https://github.com/westonganger/paper_trail-association_tracking/compare/v2.4.0...master)
|
|
4
4
|
- Nothing yet
|
|
5
5
|
|
|
6
|
+
### v2.4.0 - 2026-09-16 - [View Diff](https://github.com/westonganger/paper_trail-association_tracking/compare/v2.3.0...v2.4.0)
|
|
7
|
+
- [#59](https://github.com/westonganger/paper_trail-association_tracking/pull/59) - Pass the version object when saving `belongs_to` association rows, so `VersionAssociation` no longer loads the parent version before each INSERT under `belongs_to_required_by_default`
|
|
8
|
+
- [#56](https://github.com/westonganger/paper_trail-association_tracking/pull/56) - Defer inclusion until after active record has fully loaded
|
|
9
|
+
- [#54](https://github.com/westonganger/paper_trail-association_tracking/pull/54) - Change migration for `versions.transaction_id` to BIGINT
|
|
10
|
+
|
|
6
11
|
### v2.3.0 - 2025-04-17 - [View Diff](https://github.com/westonganger/paper_trail-association_tracking/compare/v2.2.1...v2.3.0)
|
|
7
12
|
- [#46](https://github.com/westonganger/paper_trail-association_tracking/pull/46) - Add support for custom version association class with separate database connection
|
|
8
13
|
- [#49](https://github.com/westonganger/paper_trail-association_tracking/pull/49) - Fix has_many though associations when the through association is singular
|
data/README.md
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
<a href='https://github.com/westonganger/paper_trail-association_tracking/actions' target='_blank'><img src="https://github.com/westonganger/paper_trail-association_tracking/actions/workflows/test.yml/badge.svg?branch=master" style="max-width:100%;" height='21' style='border:0px;height:21px;' border='0' alt="CI Status"></a>
|
|
5
5
|
<a href='https://rubygems.org/gems/paper_trail-association_tracking' target='_blank'><img height='21' style='border:0px;height:21px;' src='https://img.shields.io/gem/dt/paper_trail-association_tracking?color=brightgreen&label=Rubygems%20Downloads' border='0' alt='RubyGems Downloads' /></a>
|
|
6
6
|
|
|
7
|
-
Plugin for the [PaperTrail](https://github.com/paper-trail-gem/paper_trail.git) gem to track and reify associations. This gem was extracted from PaperTrail
|
|
7
|
+
Plugin for the [PaperTrail](https://github.com/paper-trail-gem/paper_trail.git) gem to track and reify associations. This gem was extracted from PaperTrail core.
|
|
8
8
|
|
|
9
9
|
**PR's will happily be accepted**
|
|
10
10
|
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
# schema for tracking associations.
|
|
3
3
|
class AddTransactionIdColumnToVersions < ActiveRecord::Migration<%= migration_version %>
|
|
4
4
|
def self.up
|
|
5
|
-
add_column :versions, :transaction_id, :
|
|
5
|
+
add_column :versions, :transaction_id, :bigint
|
|
6
6
|
add_index :versions, [:transaction_id]
|
|
7
7
|
end
|
|
8
8
|
|
|
@@ -7,14 +7,14 @@ require "paper_trail_association_tracking/reifier"
|
|
|
7
7
|
require "paper_trail_association_tracking/record_trail"
|
|
8
8
|
require "paper_trail_association_tracking/request"
|
|
9
9
|
require "paper_trail_association_tracking/paper_trail"
|
|
10
|
-
require "paper_trail_association_tracking/version_concern"
|
|
11
10
|
|
|
12
11
|
if defined?(Rails)
|
|
13
|
-
require "
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
12
|
+
require "paper_trail_association_tracking/frameworks/rails/railtie"
|
|
13
|
+
else
|
|
14
|
+
ActiveSupport.on_load(:active_record) do
|
|
15
|
+
require "paper_trail/frameworks/active_record"
|
|
16
|
+
require "paper_trail_association_tracking/frameworks/active_record"
|
|
17
|
+
end
|
|
18
18
|
end
|
|
19
19
|
|
|
20
20
|
module PaperTrailAssociationTracking
|
|
@@ -5,13 +5,10 @@ module PaperTrailAssociationTracking
|
|
|
5
5
|
|
|
6
6
|
initializer "paper_trail_association_tracking", after: "paper_trail" do
|
|
7
7
|
ActiveSupport.on_load(:active_record) do
|
|
8
|
+
require "paper_trail/frameworks/active_record"
|
|
8
9
|
require "paper_trail_association_tracking/frameworks/active_record"
|
|
9
10
|
end
|
|
10
11
|
end
|
|
11
12
|
|
|
12
|
-
config.to_prepare do
|
|
13
|
-
::PaperTrail::Version.include(::PaperTrailAssociationTracking::VersionConcern)
|
|
14
|
-
end
|
|
15
|
-
|
|
16
13
|
end
|
|
17
14
|
end
|
|
@@ -163,10 +163,9 @@ module PaperTrailAssociationTracking
|
|
|
163
163
|
# Save a single `belongs_to` association.
|
|
164
164
|
# @api private
|
|
165
165
|
def save_bt_association(assoc, version)
|
|
166
|
-
assoc_version_args =
|
|
167
|
-
version_id: version.id,
|
|
166
|
+
assoc_version_args = version_association_version_args(version).merge(
|
|
168
167
|
foreign_key_name: assoc.foreign_key
|
|
169
|
-
|
|
168
|
+
)
|
|
170
169
|
|
|
171
170
|
if assoc.options[:polymorphic]
|
|
172
171
|
foreign_type = @record.send(assoc.foreign_type)
|
|
@@ -184,6 +183,22 @@ module PaperTrailAssociationTracking
|
|
|
184
183
|
end
|
|
185
184
|
end
|
|
186
185
|
|
|
186
|
+
# Handing over the version object lets a required `belongs_to :version`
|
|
187
|
+
# validate presence from the loaded target instead of reloading the row it
|
|
188
|
+
# just wrote. Fall back to the id when the association class expects a
|
|
189
|
+
# different version class, so custom version classes keep working.
|
|
190
|
+
# @api private
|
|
191
|
+
def version_association_version_args(version)
|
|
192
|
+
reflection = @record.class.paper_trail.version_association_class.reflect_on_association(:version)
|
|
193
|
+
if reflection && version.persisted? && version.is_a?(reflection.klass)
|
|
194
|
+
{ version: version }
|
|
195
|
+
else
|
|
196
|
+
{ version_id: version.id }
|
|
197
|
+
end
|
|
198
|
+
rescue NameError
|
|
199
|
+
{ version_id: version.id }
|
|
200
|
+
end
|
|
201
|
+
|
|
187
202
|
# Returns true if the given HABTM association should be saved.
|
|
188
203
|
# @api private
|
|
189
204
|
def save_habtm_association?(assoc)
|
metadata
CHANGED
|
@@ -1,16 +1,15 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: paper_trail-association_tracking
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 2.
|
|
4
|
+
version: 2.4.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Weston Ganger
|
|
8
8
|
- Jared Beck
|
|
9
9
|
- Ben Atkins
|
|
10
|
-
autorequire:
|
|
11
10
|
bindir: bin
|
|
12
11
|
cert_chain: []
|
|
13
|
-
date:
|
|
12
|
+
date: 1980-01-02 00:00:00.000000000 Z
|
|
14
13
|
dependencies:
|
|
15
14
|
- !ruby/object:Gem::Dependency
|
|
16
15
|
name: paper_trail
|
|
@@ -101,7 +100,6 @@ files:
|
|
|
101
100
|
- lib/paper_trail_association_tracking/config.rb
|
|
102
101
|
- lib/paper_trail_association_tracking/frameworks/active_record.rb
|
|
103
102
|
- lib/paper_trail_association_tracking/frameworks/active_record/models/paper_trail/version_association.rb
|
|
104
|
-
- lib/paper_trail_association_tracking/frameworks/rails.rb
|
|
105
103
|
- lib/paper_trail_association_tracking/frameworks/rails/railtie.rb
|
|
106
104
|
- lib/paper_trail_association_tracking/model_config.rb
|
|
107
105
|
- lib/paper_trail_association_tracking/paper_trail.rb
|
|
@@ -120,7 +118,6 @@ homepage: https://github.com/westonganger/paper_trail-association_tracking
|
|
|
120
118
|
licenses:
|
|
121
119
|
- MIT
|
|
122
120
|
metadata: {}
|
|
123
|
-
post_install_message:
|
|
124
121
|
rdoc_options: []
|
|
125
122
|
require_paths:
|
|
126
123
|
- lib
|
|
@@ -135,8 +132,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
135
132
|
- !ruby/object:Gem::Version
|
|
136
133
|
version: '0'
|
|
137
134
|
requirements: []
|
|
138
|
-
rubygems_version:
|
|
139
|
-
signing_key:
|
|
135
|
+
rubygems_version: 4.0.3
|
|
140
136
|
specification_version: 4
|
|
141
137
|
summary: Plugin for the PaperTrail gem to track and reify associations
|
|
142
138
|
test_files: []
|