paper_trail 2.0.1 → 2.0.2
Sign up to get free protection for your applications and to get access to all the features.
- data/Gemfile.lock +28 -28
- data/README.md +11 -3
- data/lib/paper_trail/has_paper_trail.rb +5 -4
- data/lib/paper_trail/version_number.rb +1 -1
- metadata +4 -4
data/Gemfile.lock
CHANGED
@@ -1,40 +1,40 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
paper_trail (2.0.
|
4
|
+
paper_trail (2.0.2)
|
5
5
|
rails (~> 3)
|
6
6
|
|
7
7
|
GEM
|
8
8
|
remote: http://rubygems.org/
|
9
9
|
specs:
|
10
10
|
abstract (1.0.0)
|
11
|
-
actionmailer (3.0.
|
12
|
-
actionpack (= 3.0.
|
13
|
-
mail (~> 2.2.
|
14
|
-
actionpack (3.0.
|
15
|
-
activemodel (= 3.0.
|
16
|
-
activesupport (= 3.0.
|
11
|
+
actionmailer (3.0.4)
|
12
|
+
actionpack (= 3.0.4)
|
13
|
+
mail (~> 2.2.15)
|
14
|
+
actionpack (3.0.4)
|
15
|
+
activemodel (= 3.0.4)
|
16
|
+
activesupport (= 3.0.4)
|
17
17
|
builder (~> 2.1.2)
|
18
18
|
erubis (~> 2.6.6)
|
19
19
|
i18n (~> 0.4)
|
20
20
|
rack (~> 1.2.1)
|
21
21
|
rack-mount (~> 0.6.13)
|
22
|
-
rack-test (~> 0.5.
|
22
|
+
rack-test (~> 0.5.7)
|
23
23
|
tzinfo (~> 0.3.23)
|
24
|
-
activemodel (3.0.
|
25
|
-
activesupport (= 3.0.
|
24
|
+
activemodel (3.0.4)
|
25
|
+
activesupport (= 3.0.4)
|
26
26
|
builder (~> 2.1.2)
|
27
27
|
i18n (~> 0.4)
|
28
|
-
activerecord (3.0.
|
29
|
-
activemodel (= 3.0.
|
30
|
-
activesupport (= 3.0.
|
28
|
+
activerecord (3.0.4)
|
29
|
+
activemodel (= 3.0.4)
|
30
|
+
activesupport (= 3.0.4)
|
31
31
|
arel (~> 2.0.2)
|
32
32
|
tzinfo (~> 0.3.23)
|
33
|
-
activeresource (3.0.
|
34
|
-
activemodel (= 3.0.
|
35
|
-
activesupport (= 3.0.
|
36
|
-
activesupport (3.0.
|
37
|
-
arel (2.0.
|
33
|
+
activeresource (3.0.4)
|
34
|
+
activemodel (= 3.0.4)
|
35
|
+
activesupport (= 3.0.4)
|
36
|
+
activesupport (3.0.4)
|
37
|
+
arel (2.0.9)
|
38
38
|
builder (2.1.2)
|
39
39
|
capybara (0.4.1.1)
|
40
40
|
celerity (>= 0.7.9)
|
@@ -68,17 +68,17 @@ GEM
|
|
68
68
|
rack (>= 1.0.0)
|
69
69
|
rack-test (0.5.7)
|
70
70
|
rack (>= 1.0)
|
71
|
-
rails (3.0.
|
72
|
-
actionmailer (= 3.0.
|
73
|
-
actionpack (= 3.0.
|
74
|
-
activerecord (= 3.0.
|
75
|
-
activeresource (= 3.0.
|
76
|
-
activesupport (= 3.0.
|
71
|
+
rails (3.0.4)
|
72
|
+
actionmailer (= 3.0.4)
|
73
|
+
actionpack (= 3.0.4)
|
74
|
+
activerecord (= 3.0.4)
|
75
|
+
activeresource (= 3.0.4)
|
76
|
+
activesupport (= 3.0.4)
|
77
77
|
bundler (~> 1.0)
|
78
|
-
railties (= 3.0.
|
79
|
-
railties (3.0.
|
80
|
-
actionpack (= 3.0.
|
81
|
-
activesupport (= 3.0.
|
78
|
+
railties (= 3.0.4)
|
79
|
+
railties (3.0.4)
|
80
|
+
actionpack (= 3.0.4)
|
81
|
+
activesupport (= 3.0.4)
|
82
82
|
rake (>= 0.8.7)
|
83
83
|
thor (~> 0.14.4)
|
84
84
|
rake (0.8.7)
|
data/README.md
CHANGED
@@ -2,6 +2,7 @@
|
|
2
2
|
|
3
3
|
PaperTrail lets you track changes to your models' data. It's good for auditing or versioning. You can see how a model looked at any stage in its lifecycle, revert it to any version, and even undelete it after it's been destroyed.
|
4
4
|
|
5
|
+
There's an excellent [Railscast on implementing Undo with Paper Trail](http://railscasts.com/episodes/255-undo-with-paper-trail).
|
5
6
|
|
6
7
|
## Features
|
7
8
|
|
@@ -26,7 +27,7 @@ PaperTrail lets you track changes to your models' data. It's good for auditing
|
|
26
27
|
|
27
28
|
## Rails Version
|
28
29
|
|
29
|
-
Works on Rails 3 and Rails 2.3. The Rails 3 code is on the `master` branch and tagged `v2.x`. The Rails 2.3 code is on the `rails2` branch and tagged `v1.x`.
|
30
|
+
Works on Rails 3 and Rails 2.3. The Rails 3 code is on the `master` branch and tagged `v2.x`. The Rails 2.3 code is on the `rails2` branch and tagged `v1.x`. Please note I'm not adding new features to the Rails 2.3 codebase.
|
30
31
|
|
31
32
|
|
32
33
|
## API Summary
|
@@ -225,7 +226,7 @@ Undeleting is just as simple:
|
|
225
226
|
>> widget = Version.find(153).reify # the widget as it was before it was destroyed
|
226
227
|
>> widget.save # the widget lives!
|
227
228
|
|
228
|
-
In fact you could use PaperTrail to implement an undo system, though I haven't had the opportunity yet to do it myself.
|
229
|
+
In fact you could use PaperTrail to implement an undo system, though I haven't had the opportunity yet to do it myself. However [Ryan Bates has](http://railscasts.com/episodes/255-undo-with-paper-trail)!
|
229
230
|
|
230
231
|
|
231
232
|
## Navigating Versions
|
@@ -307,6 +308,13 @@ To find out who made a `version`'s object look that way, use `version.originator
|
|
307
308
|
>> last_version.terminator # 'Bob'
|
308
309
|
|
309
310
|
|
311
|
+
## Associations
|
312
|
+
|
313
|
+
I haven't yet found a good way to get PaperTrail to automatically restore associations when you reify a model. See [here for a little more info](http://airbladesoftware.com/notes/undo-and-redo-with-papertrail).
|
314
|
+
|
315
|
+
If you can think of a good way to achieve this, please let me know.
|
316
|
+
|
317
|
+
|
310
318
|
## Has-One Associations
|
311
319
|
|
312
320
|
PaperTrail automatically restores `:has_one` associations as they were at (actually, 3 seconds before) the time.
|
@@ -511,7 +519,7 @@ Over time your `versions` table will grow to an unwieldy size. Because each ver
|
|
511
519
|
|
512
520
|
2. Generate a migration which will add a `versions` table to your database.
|
513
521
|
|
514
|
-
`bundle exec rails generate paper_trail`
|
522
|
+
`bundle exec rails generate paper_trail:install`
|
515
523
|
|
516
524
|
3. Run the migration.
|
517
525
|
|
@@ -30,7 +30,7 @@ module PaperTrail
|
|
30
30
|
|
31
31
|
cattr_accessor :only
|
32
32
|
self.only = ([options[:only]].flatten.compact || []).map &:to_s
|
33
|
-
|
33
|
+
|
34
34
|
cattr_accessor :meta
|
35
35
|
self.meta = options[:meta] || {}
|
36
36
|
|
@@ -111,7 +111,8 @@ module PaperTrail
|
|
111
111
|
|
112
112
|
def record_destroy
|
113
113
|
if switched_on? and not new_record?
|
114
|
-
Version.create merge_metadata(:
|
114
|
+
Version.create merge_metadata(:item_id => self.id,
|
115
|
+
:item_type => self.class.name,
|
115
116
|
:event => 'destroy',
|
116
117
|
:object => object_to_string(item_before_change),
|
117
118
|
:whodunnit => PaperTrail.whodunnit)
|
@@ -122,7 +123,7 @@ module PaperTrail
|
|
122
123
|
def merge_metadata(data)
|
123
124
|
# First we merge the model-level metadata in `meta`.
|
124
125
|
meta.each do |k,v|
|
125
|
-
data[k] =
|
126
|
+
data[k] =
|
126
127
|
if v.respond_to?(:call)
|
127
128
|
v.call(self)
|
128
129
|
elsif v.is_a?(Symbol) && respond_to?(v)
|
@@ -153,7 +154,7 @@ module PaperTrail
|
|
153
154
|
def notably_changed
|
154
155
|
self.class.only.empty? ? changed_and_not_ignored : (changed_and_not_ignored & self.class.only)
|
155
156
|
end
|
156
|
-
|
157
|
+
|
157
158
|
def changed_and_not_ignored
|
158
159
|
changed - self.class.ignore
|
159
160
|
end
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: paper_trail
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 11
|
5
5
|
prerelease: false
|
6
6
|
segments:
|
7
7
|
- 2
|
8
8
|
- 0
|
9
|
-
-
|
10
|
-
version: 2.0.
|
9
|
+
- 2
|
10
|
+
version: 2.0.2
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Andy Stewart
|
@@ -15,7 +15,7 @@ autorequire:
|
|
15
15
|
bindir: bin
|
16
16
|
cert_chain: []
|
17
17
|
|
18
|
-
date: 2011-
|
18
|
+
date: 2011-03-16 00:00:00 +01:00
|
19
19
|
default_executable:
|
20
20
|
dependencies:
|
21
21
|
- !ruby/object:Gem::Dependency
|