paper_trail-active_record 0.1.1 → 0.1.2
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 +4 -0
- data/Readme.md +20 -21
- data/lib/paper_trail/active_record/or_deleted.rb +1 -1
- data/lib/paper_trail/active_record/version.rb +1 -1
- data/paper_trail-active_record.gemspec +1 -1
- metadata +6 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 28bf423183511f3a2c63c11421acfec27790f6a99985db9cf25898ab06e54f00
|
4
|
+
data.tar.gz: 6e470451542d115789496c6c91e8af14245d596fda5afba1ca0a6434c64e3b39
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e8f66e1ca525037858352c503a30793cada982d88c2c103132f99e8b087cfa971b330f42ff2e26b54dd7fda3472aa68d49a89f9a4c9ee64118d87e5a887347fd
|
7
|
+
data.tar.gz: 47c68747e77bacdd68210e07e13f458631a7e15d532e79439fc9a14e891a93bf6874889647e0ee9aaef72f58d7be7f3c992a355be54bf0887d7576c006166669
|
data/Changelog.md
CHANGED
data/Readme.md
CHANGED
@@ -3,8 +3,8 @@
|
|
3
3
|
[![Gem Version][1]][2]
|
4
4
|
[](https://rdoc.info/github/TylerRick/paper_trail-active_record/master)
|
5
5
|
|
6
|
-
|
7
|
-
|
6
|
+
Various ActiveRecord extensions to make your life easier when working with
|
7
|
+
[PaperTrail](https://github.com/paper-trail-gem/paper_trail) versions and versioned model records.
|
8
8
|
|
9
9
|
## Methods added to models with `has_paper_trail`
|
10
10
|
|
@@ -27,25 +27,7 @@ that adds some useful extensions to models that have `has_paper_trail` and to th
|
|
27
27
|
- `#action`
|
28
28
|
- `#item_class`
|
29
29
|
|
30
|
-
## `
|
31
|
-
|
32
|
-
If you include this module into a model, it will automatically add a `{association}_or_deleted`
|
33
|
-
method for every `belongs_to` or `has_one` association that is defined.
|
34
|
-
|
35
|
-
Because it reflects on all associations on that model as soon as it is included, make sure to
|
36
|
-
include it *after* all of your associations are defined.
|
37
|
-
|
38
|
-
If you want more control, and don't want it to add anything automatically, you can manually call
|
39
|
-
`define_assoc_or_deleted :association` for each association that you want to have a
|
40
|
-
`{association}_or_deleted` method.
|
41
|
-
|
42
|
-
If you want it to automatically be added for all assocations on *all* application models, you can
|
43
|
-
use [gem 'active_record_include'](https://github.com/TylerRick/active_record_include) like this:
|
44
|
-
|
45
|
-
```ruby
|
46
|
-
class ApplicationRecord < ActiveRecord::Base
|
47
|
-
include_when_connected PaperTrail::ActiveRecord::OrDeleted
|
48
|
-
```
|
30
|
+
## `{association}_or_deleted`
|
49
31
|
|
50
32
|
### `def define_assoc_or_deleted(assoc_name, suffix: nil)`
|
51
33
|
|
@@ -66,6 +48,23 @@ class Post
|
|
66
48
|
define_assoc_or_deleted :author, suffix: nil
|
67
49
|
```
|
68
50
|
|
51
|
+
### Automatically add for all assocations
|
52
|
+
|
53
|
+
If you include `PaperTrail::ActiveRecord::OrDeleted` into a model, it will automatically add a `{association}_or_deleted`
|
54
|
+
method for every `belongs_to` or `has_one` association that is defined.
|
55
|
+
|
56
|
+
Because it reflects on all associations on that model as soon as it is included, make sure to
|
57
|
+
include it *after* all of your associations are defined. You can also call
|
58
|
+
`define_assoc_or_deleted_on_all_associations` at the end of your model class (that is the same
|
59
|
+
method that including the module triggers).
|
60
|
+
|
61
|
+
If you want it to automatically be added for all assocations on *all* application models, you can
|
62
|
+
use [gem 'active_record_include'](https://github.com/TylerRick/active_record_include) like this:
|
63
|
+
|
64
|
+
```ruby
|
65
|
+
class ApplicationRecord < ActiveRecord::Base
|
66
|
+
include_when_connected PaperTrail::ActiveRecord::OrDeleted
|
67
|
+
```
|
69
68
|
|
70
69
|
|
71
70
|
## Installation
|
@@ -69,7 +69,7 @@ module OrDeleted
|
|
69
69
|
|
70
70
|
def define_assoc_or_deleted_on_all_associations(suffix: 'or_deleted')
|
71
71
|
reflect_on_all_associations.each do |reflection|
|
72
|
-
puts %(#{self}.reflection.name=#{(reflection.name).inspect})
|
72
|
+
#puts %(#{self}.reflection.name=#{(reflection.name).inspect})
|
73
73
|
next if reflection.collection?
|
74
74
|
|
75
75
|
assoc_name = reflection.name
|
@@ -9,7 +9,7 @@ Gem::Specification.new do |spec|
|
|
9
9
|
spec.authors = ["Tyler Rick"]
|
10
10
|
spec.email = ["tyler@tylerrick.com"]
|
11
11
|
|
12
|
-
spec.summary = %q{Various ActiveRecord extensions}
|
12
|
+
spec.summary = %q{Various ActiveRecord extensions to make your life easier when working with PaperTrail versions}
|
13
13
|
spec.description = spec.summary
|
14
14
|
spec.homepage = "https://github.com/TylerRick/#{spec.name}"
|
15
15
|
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: paper_trail-active_record
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Tyler Rick
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2020-04-
|
11
|
+
date: 2020-04-27 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: paper_trail
|
@@ -136,7 +136,8 @@ dependencies:
|
|
136
136
|
- - ">="
|
137
137
|
- !ruby/object:Gem::Version
|
138
138
|
version: '0'
|
139
|
-
description: Various ActiveRecord extensions
|
139
|
+
description: Various ActiveRecord extensions to make your life easier when working
|
140
|
+
with PaperTrail versions
|
140
141
|
email:
|
141
142
|
- tyler@tylerrick.com
|
142
143
|
executables: []
|
@@ -185,5 +186,6 @@ requirements: []
|
|
185
186
|
rubygems_version: 3.0.3
|
186
187
|
signing_key:
|
187
188
|
specification_version: 4
|
188
|
-
summary: Various ActiveRecord extensions
|
189
|
+
summary: Various ActiveRecord extensions to make your life easier when working with
|
190
|
+
PaperTrail versions
|
189
191
|
test_files: []
|