paper_trail 2.5.0 → 2.5.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/README.md +15 -10
- data/lib/paper_trail/has_paper_trail.rb +1 -1
- data/lib/paper_trail/version.rb +1 -1
- data/lib/paper_trail/version_number.rb +1 -1
- data/paper_trail.gemspec +0 -1
- data/test/test_helper.rb +0 -6
- metadata +4 -18
data/README.md
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
# PaperTrail [](http://travis-ci.org/airblade/paper_trail) [](https://gemnasium.com/airblade/paper_trail)
|
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
|
|
@@ -437,20 +437,24 @@ But none of these will:
|
|
437
437
|
>> @book.author_ids = [@solzhenistyn.id, @dostoyevsky.id]
|
438
438
|
>> @book.authors = []
|
439
439
|
|
440
|
-
Having said that, you can apparently get all these working (I haven't tested it myself) with this
|
440
|
+
Having said that, you can apparently get all these working (I haven't tested it myself) with this patch:
|
441
441
|
|
442
|
-
# In config/initializers/
|
443
|
-
ActiveRecord
|
444
|
-
|
445
|
-
|
446
|
-
|
447
|
-
|
442
|
+
# In config/initializers/active_record_patch.rb
|
443
|
+
module ActiveRecord
|
444
|
+
# = Active Record Has Many Through Association
|
445
|
+
module Associations
|
446
|
+
class HasManyThroughAssociation < HasManyAssociation #:nodoc:
|
447
|
+
alias_method :original_delete_records, :delete_records
|
448
|
+
|
449
|
+
def delete_records(records, method)
|
450
|
+
method ||= :destroy
|
451
|
+
original_delete_records(records, method)
|
452
|
+
end
|
448
453
|
end
|
449
454
|
end
|
450
455
|
end
|
451
456
|
|
452
|
-
|
453
|
-
|
457
|
+
See [issue 113](https://github.com/airblade/paper_trail/issues/113) for a discussion about this.
|
454
458
|
|
455
459
|
There may be a way to store authorship versions, probably using association callbacks, no matter how the collection is manipulated but I haven't found it yet. Let me know if you do.
|
456
460
|
|
@@ -689,6 +693,7 @@ Many thanks to:
|
|
689
693
|
* [Nicholas Thrower](https://github.com/throwern)
|
690
694
|
* [Benjamin Curtis](https://github.com/stympy)
|
691
695
|
* [Peter Harkins](https://github.com/pushcx)
|
696
|
+
* [Mohd Amree](https://github.com/amree)
|
692
697
|
|
693
698
|
|
694
699
|
## Inspirations
|
@@ -97,7 +97,7 @@ module PaperTrail
|
|
97
97
|
def version_at(timestamp, reify_options={})
|
98
98
|
# Because a version stores how its object looked *before* the change,
|
99
99
|
# we need to look for the first version created *after* the timestamp.
|
100
|
-
v = send(self.class.versions_association_name).
|
100
|
+
v = send(self.class.versions_association_name).following(timestamp).first
|
101
101
|
v ? v.reify(reify_options) : self
|
102
102
|
end
|
103
103
|
|
data/lib/paper_trail/version.rb
CHANGED
@@ -15,7 +15,7 @@ class Version < ActiveRecord::Base
|
|
15
15
|
where(["#{self.primary_key} < ?", version.is_a?(self) ? version.id : version]).order("#{self.primary_key} DESC")
|
16
16
|
}
|
17
17
|
|
18
|
-
scope :
|
18
|
+
scope :following, lambda { |timestamp|
|
19
19
|
# TODO: is this :order necessary, considering its presence on the has_many :versions association?
|
20
20
|
where(['created_at > ?', timestamp]).order("created_at ASC, #{self.primary_key} ASC")
|
21
21
|
}
|
data/paper_trail.gemspec
CHANGED
data/test/test_helper.rb
CHANGED
@@ -4,12 +4,6 @@ ENV["RAILS_ENV"] = "test"
|
|
4
4
|
require File.expand_path("../dummy/config/environment.rb", __FILE__)
|
5
5
|
require "rails/test_help"
|
6
6
|
|
7
|
-
begin
|
8
|
-
require 'turn'
|
9
|
-
rescue LoadError
|
10
|
-
# noop
|
11
|
-
end
|
12
|
-
|
13
7
|
#ActionMailer::Base.delivery_method = :test
|
14
8
|
#ActionMailer::Base.perform_deliveries = true
|
15
9
|
#ActionMailer::Base.default_url_options[:host] = "test.com"
|
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: 31
|
5
5
|
prerelease:
|
6
6
|
segments:
|
7
7
|
- 2
|
8
8
|
- 5
|
9
|
-
-
|
10
|
-
version: 2.5.
|
9
|
+
- 2
|
10
|
+
version: 2.5.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:
|
18
|
+
date: 2012-01-16 00:00:00 +01:00
|
19
19
|
default_executable:
|
20
20
|
dependencies:
|
21
21
|
- !ruby/object:Gem::Dependency
|
@@ -93,20 +93,6 @@ dependencies:
|
|
93
93
|
version: 0.4.0
|
94
94
|
type: :development
|
95
95
|
version_requirements: *id005
|
96
|
-
- !ruby/object:Gem::Dependency
|
97
|
-
name: turn
|
98
|
-
prerelease: false
|
99
|
-
requirement: &id006 !ruby/object:Gem::Requirement
|
100
|
-
none: false
|
101
|
-
requirements:
|
102
|
-
- - ">="
|
103
|
-
- !ruby/object:Gem::Version
|
104
|
-
hash: 3
|
105
|
-
segments:
|
106
|
-
- 0
|
107
|
-
version: "0"
|
108
|
-
type: :development
|
109
|
-
version_requirements: *id006
|
110
96
|
description: Track changes to your models' data. Good for auditing or versioning.
|
111
97
|
email: boss@airbladesoftware.com
|
112
98
|
executables: []
|