acts_as_tracked 1.0.0 → 1.0.2
Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 7bdeaabe771f68654d6ccf3728485a212801ee2e8f18bc637953c3c822c0f5c7
|
4
|
+
data.tar.gz: c44e7cc2cffdbce56cc13e95e54a6ea28e267ffac71ecaa46f0ad56e652a45b1
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 21b20a551df69c57b0379ef45157e65dd8c51f6db4f0fe71454ece79b487ef118fd28add076288bb9e2a66774f4749b449ad0e3b660b67cf91eaeaeae3481b6f
|
7
|
+
data.tar.gz: 65f261411562f9d336cbbe692ef093f5bbf504a29a008abe80004257b0413d47c96398b8b5858b239d33cb9d2e7ec539b15ad4afe80aa730a80f19aad8b4abe2
|
data/README.md
CHANGED
@@ -1,13 +1,13 @@
|
|
1
|
-
[![Gem Version](https://badge.fury.io/rb/
|
1
|
+
[![Gem Version](https://badge.fury.io/rb/acts_as_tracked.svg)](https://badge.fury.io/rb/acts_as_tracked)
|
2
2
|
[![CircleCI](https://circleci.com/gh/ramblingcode/acts-as-tracked.svg?style=svg)](https://circleci.com/gh/ramblingcode/acts-as-tracked)
|
3
3
|
[![codecov](https://codecov.io/gh/ramblingcode/acts-as-tracked/branch/master/graph/badge.svg)](https://codecov.io/gh/ramblingcode/acts-as-tracked)
|
4
4
|
|
5
5
|
|
6
6
|
# ActsAsTracked
|
7
7
|
|
8
|
-
Welcome to ActsAsTracked! This gem is an extension to your ActiveRecord models to track activities. It does not track everything all the time, but can be used wherever you find it necessary to have a history for changes alongside their actors.
|
8
|
+
Welcome to ActsAsTracked! This gem is an extension to your ActiveRecord models to track activities. It does not track everything all the time or in the background, but can be used wherever you find it necessary to have a history for changes alongside their actors.
|
9
9
|
|
10
|
-
There are few other gems such as [audited](https://github.com/collectiveidea/audited), however, it is tracking every change on your models. ActsAsTracked is controlled by `you` and will track changes only when `used
|
10
|
+
There are few other gems such as [audited](https://github.com/collectiveidea/audited), however, it is tracking every change on your models. ActsAsTracked is controlled by `you` and will track changes only when `used explicitly`.
|
11
11
|
|
12
12
|
## Installation
|
13
13
|
|
@@ -20,13 +20,13 @@ gem 'acts_as_tracked'
|
|
20
20
|
And then execute:
|
21
21
|
|
22
22
|
```shell
|
23
|
-
|
23
|
+
bundle install
|
24
24
|
```
|
25
25
|
|
26
26
|
Or install it yourself as:
|
27
27
|
|
28
28
|
```shell
|
29
|
-
|
29
|
+
gem install acts_as_tracked
|
30
30
|
```
|
31
31
|
|
32
32
|
## Usage
|
@@ -44,15 +44,12 @@ ActsAsTracked has extension to generate migrations. Please, run:
|
|
44
44
|
This will generate following migration:
|
45
45
|
|
46
46
|
```ruby
|
47
|
-
class ActsAsTrackedMigration < ActiveRecord::Migration
|
47
|
+
class ActsAsTrackedMigration < ActiveRecord::Migration
|
48
48
|
def self.up
|
49
49
|
create_table :activities do |t|
|
50
|
-
t.
|
51
|
-
t.
|
52
|
-
t.
|
53
|
-
t.string :subject_type
|
54
|
-
t.integer :parent_id, index: true
|
55
|
-
t.string :parent_type
|
50
|
+
t.references :actor, polymorphic: true
|
51
|
+
t.references :subject, polymorphic: true
|
52
|
+
t.references :parent, polymorphic: true
|
56
53
|
t.text :attribute_changes
|
57
54
|
t.string :activity_type
|
58
55
|
t.string :human_description
|
@@ -79,7 +76,7 @@ If you would like to track changes of `Post` model, you would need to call `acts
|
|
79
76
|
# You may optionally pass in exluded_activity_attributes
|
80
77
|
# as an argument to not track given fields.
|
81
78
|
#
|
82
|
-
# acts_as_tracked(exclude_activity_attributes: %i[
|
79
|
+
# acts_as_tracked(exclude_activity_attributes: %i[api_key, username])
|
83
80
|
end
|
84
81
|
```
|
85
82
|
|
@@ -160,13 +157,41 @@ Post.tracking_changes(actor: User.first, subject: Post.first, human_description:
|
|
160
157
|
end
|
161
158
|
```
|
162
159
|
|
160
|
+
### Excluding attributes from change sets
|
161
|
+
|
162
|
+
Sometimes you would like to not track some fields of the record in change sets.
|
163
|
+
|
164
|
+
You can use exclude_activity_attributes and ActsAsTracked will not include them in activities.
|
165
|
+
|
166
|
+
```ruby
|
167
|
+
class Post < ApplicationRecord
|
168
|
+
acts_as_tracked(exclude_activity_attributes: %i[api_key, username])
|
169
|
+
end
|
170
|
+
```
|
171
|
+
|
172
|
+
### Differences between [PaperTrail](https://github.com/paper-trail-gem/paper_trail), [Audited](https://github.com/collectiveidea/audited), and [PublicActivity](https://github.com/chaps-io/public_activity) gems
|
173
|
+
|
174
|
+
Main difference is that ActsAsTracked does not track anything unless used `explicitly`. It does not store versions of the record that you can rollback to.
|
175
|
+
|
176
|
+
It's minimal, and only does 1 thing, that is creating activity records with change sets whenever used.
|
177
|
+
|
178
|
+
It's a feature extension to your models to use when *needed*, instead of being a hook that acts in the background.
|
179
|
+
|
180
|
+
```ruby
|
181
|
+
Post.tracking_changes(actor: @user) do
|
182
|
+
...changes on posts
|
183
|
+
end
|
184
|
+
```
|
185
|
+
|
186
|
+
You can check the `tracking` module which is just a shy over 100 lines that gets plugged in your models [here](https://github.com/ramblingcode/acts-as-tracked/blob/master/lib/acts_as_tracked/tracking.rb).
|
187
|
+
|
163
188
|
### Example application using ActsAsTracked
|
164
189
|
|
165
190
|
I have created a Rails 6 application with the usages of ActsAsTracked. Please refer to this [repo](https://github.com/ramblingcode/rails6-acts-as-tracked-usage)
|
166
191
|
|
167
192
|
## Credits
|
168
193
|
|
169
|
-
Initial work of ActsAsTracked has been done by @rogercampos and @camaloon team. I have refined, packaged, documented, added generators and published it.
|
194
|
+
Initial work of ActsAsTracked has been done by [@rogercampos](https://github.com/rogercampos) and [@camaloon](https://github.com/camaloon) team. I have refined, packaged, documented, added generators and published it.
|
170
195
|
|
171
196
|
## Development
|
172
197
|
|
@@ -176,7 +201,7 @@ To install this gem onto your local machine, run `bundle exec rake install`. To
|
|
176
201
|
|
177
202
|
## Contributing
|
178
203
|
|
179
|
-
Bug reports and pull requests are welcome on GitHub at https://github.com/ramblingcode/
|
204
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/ramblingcode/acts-as-tracked. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [code of conduct](https://github.com/[USERNAME]/acts_as_tracked/blob/master/CODE_OF_CONDUCT.md).
|
180
205
|
|
181
206
|
## License
|
182
207
|
|
@@ -1,12 +1,9 @@
|
|
1
1
|
class ActsAsTrackedMigration < ActiveRecord::Migration<%= migration_version %>
|
2
2
|
def self.up
|
3
3
|
create_table :activities do |t|
|
4
|
-
t.
|
5
|
-
t.
|
6
|
-
t.
|
7
|
-
t.string :subject_type
|
8
|
-
t.integer :parent_id, index: true
|
9
|
-
t.string :parent_type
|
4
|
+
t.references :actor, polymorphic: true
|
5
|
+
t.references :subject, polymorphic: true
|
6
|
+
t.references :parent, polymorphic: true
|
10
7
|
t.text :attribute_changes
|
11
8
|
t.string :activity_type
|
12
9
|
t.string :human_description
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: acts_as_tracked
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Sahil Gadimbayli
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2020-06-
|
11
|
+
date: 2020-06-28 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: actionview
|