paper_trail 2.0.1 → 2.0.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.
data/Gemfile.lock CHANGED
@@ -1,40 +1,40 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- paper_trail (2.0.1)
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.3)
12
- actionpack (= 3.0.3)
13
- mail (~> 2.2.9)
14
- actionpack (3.0.3)
15
- activemodel (= 3.0.3)
16
- activesupport (= 3.0.3)
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.6)
22
+ rack-test (~> 0.5.7)
23
23
  tzinfo (~> 0.3.23)
24
- activemodel (3.0.3)
25
- activesupport (= 3.0.3)
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.3)
29
- activemodel (= 3.0.3)
30
- activesupport (= 3.0.3)
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.3)
34
- activemodel (= 3.0.3)
35
- activesupport (= 3.0.3)
36
- activesupport (3.0.3)
37
- arel (2.0.7)
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.3)
72
- actionmailer (= 3.0.3)
73
- actionpack (= 3.0.3)
74
- activerecord (= 3.0.3)
75
- activeresource (= 3.0.3)
76
- activesupport (= 3.0.3)
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.3)
79
- railties (3.0.3)
80
- actionpack (= 3.0.3)
81
- activesupport (= 3.0.3)
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(:item => self,
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
@@ -1,3 +1,3 @@
1
1
  module PaperTrail
2
- VERSION = '2.0.1'
2
+ VERSION = '2.0.2'
3
3
  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: 13
4
+ hash: 11
5
5
  prerelease: false
6
6
  segments:
7
7
  - 2
8
8
  - 0
9
- - 1
10
- version: 2.0.1
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-02-25 00:00:00 +00:00
18
+ date: 2011-03-16 00:00:00 +01:00
19
19
  default_executable:
20
20
  dependencies:
21
21
  - !ruby/object:Gem::Dependency