mongoid-audit 0.3.2 → 1.0.0.alpha.1

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
  SHA1:
3
- metadata.gz: 2f22e64db40fe3fc2abd49b9256511a5787994ac
4
- data.tar.gz: cc6fc81cb903b782850aff4f3813dbbe720e82a6
3
+ metadata.gz: 0057de0bc4b8086ede177d4e62f00f2afe911a9c
4
+ data.tar.gz: a3bc47897234907ac0febea43b6d7062f04be122
5
5
  SHA512:
6
- metadata.gz: 3a88f20f072b6f285ec0120246f43f07741c3a38aa330f5ad23ec80273ddd1a401be6f28c2d8e59d928d09e374ad15a4c838cffa4e4a7b24d86c9ed6fd427de3
7
- data.tar.gz: da8e1441856ff92dcbd0c091d736b1e59077e6761f14818f724cae4302675f0aed15bd45d0a7627ac2c84359ab403dc4b7d1fc18b6285f9f86b19f578af46a6b
6
+ metadata.gz: 4ced31227b1dbdb9bd575ee5d48e03642e2574aa3b1df4836a54f08709cf42e4b24bb6c6c148ad822a442e22372f59bb5bb0180b013a95f82422aff0411f138d
7
+ data.tar.gz: b6decdc95280890a88824fc4ec47e3fc8c7c6b08cc488ada2e9208b0eb81240f9cd1796e758118f5b2cd8d74ab235c97b8f97592ec89cf6f908198eae493356c
data/.gitignore CHANGED
@@ -3,7 +3,6 @@
3
3
  .bundle
4
4
  .config
5
5
  .yardoc
6
- Gemfile.lock
7
6
  InstalledFiles
8
7
  _yardoc
9
8
  coverage
data/.ruby-version CHANGED
@@ -1 +1 @@
1
- ruby-2.0.0-p247
1
+ 2.1.2
data/Gemfile.lock ADDED
@@ -0,0 +1,74 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ mongoid-audit (1.0.0.alpha.1)
5
+ activesupport
6
+ glebtv_mongoid_userstamp
7
+ kaminari
8
+ mongoid (~> 4.0.0)
9
+ mongoid-history (~> 0.4.4)
10
+
11
+ GEM
12
+ remote: https://rubygems.org/
13
+ specs:
14
+ actionpack (4.1.4)
15
+ actionview (= 4.1.4)
16
+ activesupport (= 4.1.4)
17
+ rack (~> 1.5.2)
18
+ rack-test (~> 0.6.2)
19
+ actionview (4.1.4)
20
+ activesupport (= 4.1.4)
21
+ builder (~> 3.1)
22
+ erubis (~> 2.7.0)
23
+ activemodel (4.1.4)
24
+ activesupport (= 4.1.4)
25
+ builder (~> 3.1)
26
+ activesupport (4.1.4)
27
+ i18n (~> 0.6, >= 0.6.9)
28
+ json (~> 1.7, >= 1.7.7)
29
+ minitest (~> 5.1)
30
+ thread_safe (~> 0.1)
31
+ tzinfo (~> 1.1)
32
+ bson (2.3.0)
33
+ builder (3.2.2)
34
+ connection_pool (2.0.0)
35
+ easy_diff (0.0.3)
36
+ erubis (2.7.0)
37
+ glebtv_mongoid_userstamp (0.4.1)
38
+ mongoid (~> 4.0.0.beta1)
39
+ i18n (0.6.11)
40
+ json (1.8.1)
41
+ kaminari (0.16.1)
42
+ actionpack (>= 3.0.0)
43
+ activesupport (>= 3.0.0)
44
+ minitest (5.4.0)
45
+ mongoid (4.0.0)
46
+ activemodel (~> 4.0)
47
+ moped (~> 2.0.0)
48
+ origin (~> 2.1)
49
+ tzinfo (>= 0.3.37)
50
+ mongoid-history (0.4.4)
51
+ activesupport
52
+ easy_diff
53
+ mongoid (>= 3.0)
54
+ moped (2.0.0)
55
+ bson (~> 2.2)
56
+ connection_pool (~> 2.0)
57
+ optionable (~> 0.2.0)
58
+ optionable (0.2.0)
59
+ origin (2.1.1)
60
+ rack (1.5.2)
61
+ rack-test (0.6.2)
62
+ rack (>= 1.0)
63
+ rake (10.3.2)
64
+ thread_safe (0.3.4)
65
+ tzinfo (1.2.2)
66
+ thread_safe (~> 0.1)
67
+
68
+ PLATFORMS
69
+ ruby
70
+
71
+ DEPENDENCIES
72
+ bundler
73
+ mongoid-audit!
74
+ rake
data/README.md CHANGED
@@ -1,31 +1,32 @@
1
- Mongoid::Audit
2
- ==============
1
+ ## Mongoid::Audit
3
2
 
4
- Mongoid Audit is a fork of mongoid-history https://github.com/aq1018/mongoid-history
3
+ [![Gem Version](https://badge.fury.io/rb/mongoid-audit.png)](http://badge.fury.io/rb/mongoid-audit)
4
+ [![Dependency Status](https://www.versioneye.com/user/projects/53ea131f8b6db55f150000b7/badge.svg)](https://www.versioneye.com/user/projects/53ea131f8b6db55f150000b7)
5
+ [![Issues](http://img.shields.io/github/issues/rs-pro/mongoid-audit.svg)](https://github.com/rs-pro/mongoid-audit/issues)
6
+ [![License](http://img.shields.io/:license-mit-blue.svg)](https://github.com/rs-pro/mongoid-audit/blob/master/MIT-LICENSE.txt)
5
7
 
6
- Fork differences:
7
- * Rails 4 support
8
- * Built in rails_admin auditing support
9
- * Properly setting user (modifier) all the time
8
+ **MongoidAudit 1.0 is a complete rewrite and might break backwards compatibility**
10
9
 
11
- In case of problems, you can try mongoid-history, which didn't work properly for us.
10
+ Since 1.0.0, mongoid_audit is no longer a fork, but a wrapper of [mongoid-history](https://github.com/aq1018/mongoid-history), providing
11
+ out-of-the-box Userstamp, RailsAdmin integration and easier setup and configuration.
12
12
 
13
- [![Build Status](https://secure.travis-ci.org/rs-pro/mongoid-audit.png?branch=master)](http://travis-ci.org/rs-pro/mongoid-audit)
14
- [![Dependency Status](https://gemnasium.com/rs-pro/mongoid-audit.png)](https://gemnasium.com/rs-pro/mongoid-audit)
15
- [![Coverage Status](https://coveralls.io/repos/rs-pro/mongoid-audit/badge.png?branch=master)](https://coveralls.io/r/rs-pro/mongoid-audit?branch=master)
16
- [![Gem Version](https://badge.fury.io/rb/mongoid-audit.png)](http://badge.fury.io/rb/mongoid-audit)
13
+ Database storage format for user / modifier in 1.0.0 was changed, since now glebtv_mongoid_userstamp gem is used to store
14
+ modifier.
15
+
16
+ To migrate your data do:
17
+
18
+ HistoryTracker.all.each{|ht| ht.rename(:modifier_id, :updater_id)
17
19
 
18
- Mongoid-audit tracks historical changes for any document, including embedded ones. It achieves this by storing all history tracks in a single collection that you define. Embedded documents are referenced by storing an association path, which is an array of `document_name` and `document_id` fields starting from the top most parent document and down to the embedded document that should track history.
20
+ This gem includes storing modifier, but it is done via ```glebtv_mongoid_userstamp``` and not directly.
19
21
 
20
- This gem also implements multi-user undo, which allows users to undo any history change in any order. Undoing a document also creates a new history track. This is great for auditing and preventing vandalism, but is probably not suitable for use cases such as a wiki.
22
+ RailsAdmin history is fully supported.
21
23
 
22
- Installation
23
- ____________
24
+ ## Installation
24
25
 
25
26
  Add this line to your application's Gemfile:
26
27
 
27
28
  # must be after rails_admin, if you use it
28
- gem 'mongoid-audit'
29
+ gem 'mongoid-audit', '~> 1.0.0.alpha.1'
29
30
 
30
31
  And then execute:
31
32
 
@@ -33,173 +34,39 @@ And then execute:
33
34
 
34
35
  Or install it yourself as:
35
36
 
36
- $ gem install mongoid-audit
37
-
38
- Usage
39
- -----
40
-
41
- **Rails Admin Integration**
42
-
43
- # note that instead of a user class, you pass in history tracker table name as second argument
44
- config.audit_with :mongoid_audit, 'HistoryTracker'
45
-
46
-
47
- **Create a history tracker**
48
-
49
- Create a new class to track histories. All histories are stored in this tracker. The name of the class can be anything you like. The only requirement is that it includes `Mongoid::Audit::Tracker`
50
-
51
- ```ruby
52
- # app/models/history_tracker.rb
53
- class HistoryTracker
54
- include Mongoid::Audit::Tracker
55
- end
56
- ```
57
-
58
- **Set tracker class name**
59
-
60
- Manually set the tracker class name to make sure your tracker can be found and loaded properly. You can skip this step if you manually require your tracker before using any trackables.
61
-
62
- The following example sets the tracker class name using a Rails initializer.
63
-
64
- ```ruby
65
- # config/initializers/mongoid-audit.rb
66
- # initializer for mongoid-audit
67
- # assuming HistoryTracker is your tracker class
68
- Mongoid::Audit.tracker_class_name = :history_tracker
69
- ```
70
-
71
- **Set `#current_user` method name**
72
-
73
- You can set the name of the method that returns currently logged in user if you don't want to set `modifier` explicitly on every update.
74
-
75
- The following example sets the `current_user_method` using a Rails initializer
76
-
77
- ```ruby
78
- # config/initializers/mongoid-audit.rb
79
- # initializer for mongoid-audit
80
- # assuming you're using devise/authlogic
81
- Mongoid::Audit.current_user_method = :current_user
82
- ```
83
-
84
- **IMPORTANT**
85
- for this to work in development environment, add
86
- ```ruby
87
- require_dependency 'history_tracker.rb' if Rails.env == "development"
88
- ```
89
- to the initializer so controller filter would be installed
90
-
37
+ $ gem install mongoid-audit --pre
91
38
 
92
- When `current_user_method` is set, mongoid-audit will invoke this method on each update and set its result as the instance modifier.
39
+ ## Usage
93
40
 
94
- ```ruby
95
- # assume that current_user return #<User _id: 1>
96
- post = Post.first
97
- post.update_attributes(:title => 'New title')
41
+ Include ```Trackable``` in your models. That's it, you are done!
98
42
 
99
- post.history_tracks.last.modifier #=> #<User _id: 1>
100
- ```
43
+ include Trackable
101
44
 
102
- **Create trackable classes and objects**
45
+ ## Advanced usage
103
46
 
104
- ```ruby
105
- class Post
106
- include Mongoid::Document
107
- include Mongoid::Timestamps
47
+ Identical to Mongoid::History.
48
+ See https://github.com/aq1018/mongoid-history
108
49
 
109
- # history tracking all Post documents
110
- # note: tracking will not work until #track_history is invoked
111
- include Mongoid::Audit::Trackable
50
+ include Mongoid::History::Trackable
51
+ track_history({
52
+ track_create: true,
53
+ track_destroy: true,
54
+ track_update: true,
55
+ modifier_field: :updater,
56
+ except: ["created_at", "updated_at", "c_at", "u_at"],
57
+ })
112
58
 
113
- field :title
114
- field :body
115
- field :rating
116
- embeds_many :comments
59
+ ### Rails Admin Integration
117
60
 
118
- # telling Mongoid::Audit how you want to track changes
119
- track_history :on => [:title, :body], # track title and body fields only, default is :all
120
- :modifier_field => :modifier, # adds "referenced_in :modifier" to track who made the change, default is :modifier
121
- :version_field => :version, # adds "field :version, :type => Integer" to track current version, default is :version
122
- :track_create => false, # track document creation, default is false
123
- :track_update => true, # track document updates, default is true
124
- :track_destroy => false # track document destruction, default is false
125
- end
61
+ Add
126
62
 
127
- class Comment
128
- include Mongoid::Document
129
- include Mongoid::Timestamps
63
+ config.audit_with :mongoid_audit
130
64
 
131
- # declare that we want to track comments
132
- include Mongoid::Audit::Trackable
133
-
134
- field :title
135
- field :body
136
- embedded_in :post, :inverse_of => :comments
137
-
138
- # track title and body for all comments, scope it to post (the parent)
139
- # also track creation and destruction
140
- track_history :on => [:title, :body], :scope => :post, :track_create => true, :track_destroy => true
141
- end
142
-
143
- # the modifier class
144
- class User
145
- include Mongoid::Document
146
- include Mongoid::Timestamps
147
-
148
- field :name
149
- end
150
-
151
- user = User.create(:name => "Aaron")
152
- post = Post.create(:title => "Test", :body => "Post", :modifier => user)
153
- comment = post.comments.create(:title => "test", :body => "comment", :modifier => user)
154
- comment.history_tracks.count # should be 1
155
-
156
- comment.update_attributes(:title => "Test 2")
157
- comment.history_tracks.count # should be 2
158
-
159
- track = comment.history_tracks.last
160
-
161
- track.undo! user # comment title should be "Test"
162
-
163
- track.redo! user # comment title should be "Test 2"
164
-
165
- # undo last change
166
- comment.undo! user
167
-
168
- # undo versions 1 - 4
169
- comment.undo! user, :from => 4, :to => 1
170
-
171
- # undo last 3 versions
172
- comment.undo! user, :last => 3
173
-
174
- # redo versions 1 - 4
175
- comment.redo! user, :from => 1, :to => 4
176
-
177
- # redo last 3 versions
178
- comment.redo! user, :last => 3
179
-
180
- # delete post
181
- post.destroy
182
-
183
- # undelete post
184
- post.undo! user
185
-
186
- # disable tracking for comments within a block
187
- Comment.disable_tracking do
188
- comment.update_attributes(:title => "Test 3")
189
- end
190
- ```
191
- For more examples, check out [spec/integration/integration_spec.rb](https://github.com/aq1018/mongoid-history/blob/master/spec/integration/integration_spec.rb).
65
+ in ```config/initializers/rails_admin.rb```
192
66
 
193
67
  ## Credits
194
68
 
195
- This gem is based on https://github.com/aq1018/mongoid-history
196
-
197
- The original gem didn't work correctly for us, when not setting modifier manually, so we rewrote it a bit.
198
- Seems to work fully now, including manually setting modifier
199
-
200
- Mongoid-history Copyright (c) 2011-2012 Aaron Qian. MIT License. See [LICENSE.txt](https://github.com/aq1018/mongoid-history/blob/master/LICENSE.txt) for further details.
201
-
202
- Mongoid-audit Copyright (c) 2013 http://rocketscience.pro MIT License.
69
+ (c) 2013-2014 http://rocketscience.pro MIT License.
203
70
 
204
71
  ## Contributing
205
72
 
data/Rakefile CHANGED
@@ -1,14 +1,2 @@
1
1
  require "bundler/gem_tasks"
2
2
 
3
- # Get your spec rake tasks working in RSpec 2.0
4
-
5
- require 'rspec/core/rake_task'
6
-
7
- desc 'Default: run specs.'
8
- task :default => :spec
9
-
10
- desc "Run specs"
11
- RSpec::Core::RakeTask.new do |t|
12
- t.pattern = "./spec/**/*_spec.rb" # don't need this, it's default.
13
- # Put spec opts in a file named .rspec in root
14
- end
data/config/mongoid.yml CHANGED
File without changes
data/lib/mongoid-audit.rb CHANGED
@@ -1,34 +1,21 @@
1
- require 'mongoid-audit/version'
2
- require 'easy_diff'
3
1
  require 'mongoid'
4
- require 'rails-observers'
5
- require 'rails/observers/active_model/active_model'
6
-
7
- module Mongoid
8
- module Audit
9
- mattr_accessor :tracker_class_name
10
- mattr_accessor :trackable_class_options
11
- mattr_accessor :modifier_class_name
12
- mattr_accessor :current_user_method
13
-
14
- def self.tracker_class
15
- @tracker_class ||= tracker_class_name.to_s.classify.constantize
16
- end
17
- end
18
- end
2
+ require 'mongoid-history'
3
+ require 'mongoid_userstamp'
4
+ require 'kaminari'
5
+ require 'kaminari/hooks'
6
+ require 'kaminari/models/mongoid_extension'
19
7
 
20
- if defined? Rails::Railtie
21
- require 'mongoid-audit/railtie'
22
- end
8
+ require 'mongoid-audit/version'
9
+ require 'mongoid-audit/trackable'
10
+ require 'mongoid-audit/history_tracker'
11
+ require 'mongoid-audit/railtie'
23
12
 
24
- if Object.const_defined?("RailsAdmin")
13
+ begin; require 'rails_admin'; rescue LoadError; end
14
+ if defined? ::RailsAdmin
25
15
  require "mongoid-audit/rails_admin"
26
16
  end
27
17
 
28
- require 'mongoid-audit/tracker'
29
- require 'mongoid-audit/trackable'
30
- require 'mongoid-audit/sweeper'
18
+ Mongoid::History.tracker_class_name = :history_tracker
19
+ Mongoid::History.current_user_method = :current_user
20
+ Mongoid::History.modifier_class_name = "User"
31
21
 
32
- Mongoid::Audit.modifier_class_name = "User"
33
- Mongoid::Audit.trackable_class_options = {}
34
- Mongoid::Audit.current_user_method ||= :current_user
@@ -0,0 +1,6 @@
1
+ class HistoryTracker
2
+ include Mongoid::History::Tracker
3
+ include Mongoid::Userstamp
4
+ include Kaminari::MongoidExtension::Document
5
+ end
6
+
@@ -1,108 +1,119 @@
1
- module RailsAdmin
2
- module Extensions
3
- module MongoidAudit
4
- class VersionProxy
5
- def initialize(version)
6
- @version = version
7
- end
8
-
9
- def message
10
- @message = @version.action
11
- mods = @version.modified.to_a.map do |c|
12
- if c[1].class.name == "Moped::BSON::Binary" || c[1].class.name == "BSON::Binary"
13
- c[0] + " = {binary data}"
14
- elsif c[1].to_s.length > 220
15
- c[0] + " = " + c[1].to_s[0..200]
16
- else
17
- c[0] + " = " + c[1].to_s
18
- end
19
-
20
- end
21
- @version.respond_to?(:modified) ? @message + ' ' + table + " [" + mods.join(", ") + "]" : @message
22
- end
23
-
24
- def created_at
25
- @version.created_at
26
- end
27
-
28
- def table
29
- @version.association_chain.last['name']
30
- end
31
-
32
- def username
33
- @version.modifier.try(:email) || @version.modifier
34
- end
35
-
36
- def item
37
- @version.association_chain.last['id']
38
- end
39
- end
40
-
41
- class AuditingAdapter
42
- COLUMN_MAPPING = {
43
- :table => 'association_chain.name',
44
- :username => 'modifier_id',
45
- :item => 'association_chain.id',
46
- :created_at => :created_at,
47
- :message => :action
48
- }
49
-
50
- def initialize(controller, version_class = HistoryTracker)
51
- @controller = controller
52
- @version_class = version_class.to_s.constantize
53
- end
54
-
55
- def latest
56
- @version_class.order_by([:_id, :desc]).limit(20).map { |version| VersionProxy.new(version) }
57
- end
58
-
59
- def delete_object(object, model, user)
60
- # do nothing
61
- end
62
-
63
- def update_object(object, model, user, changes)
64
- # do nothing
65
- end
66
-
67
- def create_object(object, abstract_model, user)
68
- # do nothing
69
- end
70
-
71
- def listing_for_model(model, query, sort, sort_reverse, all, page, per_page = (RailsAdmin::Config.default_items_per_page || 20))
72
- history = @version_class.where('association_chain.name' => model.model_name)
73
- history = history.any_of({action: /.*#{query}.*/}, {modifier_id: /.*#{query}.*/}) if query.present?
74
- if sort
75
- order = sort_reverse == "true" ? :desc : :asc
76
- history = history.order_by(sort.to_sym => order)
77
- else
78
- history = history.order_by(created_at: :desc)
79
- end
80
-
81
- history = all ? history.entries : history.send(Kaminari.config.page_method_name, page.presence || "1").per(per_page)
82
-
83
- history.map{|version| VersionProxy.new(version)}
84
- end
85
-
86
- def listing_for_object(model, object, query, sort, sort_reverse, all, page, per_page = (RailsAdmin::Config.default_items_per_page || 20))
87
- history = @version_class.where('association_chain.name' => model.model_name, 'association_chain.id' => object.id)
88
- history = history.any_of({action: /.*#{query}.*/}, {username: /.*#{query}.*/}) if query.present?
89
- if sort
90
- order = sort_reverse == "true" ? :desc : :asc
91
- history = history.order_by(sort.to_sym => order)
92
- else
93
- history = history.order_by(created_at: :desc)
94
- end
95
- history = all ? history.entries : history.send(Kaminari.config.page_method_name, page.presence || "1").per(per_page)
96
-
97
- history.map{|version| VersionProxy.new(version)}
98
- end
99
- end
100
- end
101
- end
102
- end
103
-
104
-
105
-
106
- RailsAdmin.add_extension(:mongoid_audit, RailsAdmin::Extensions::MongoidAudit, {
107
- :auditing => true
108
- })
1
+ module RailsAdmin
2
+ module Extensions
3
+ module MongoidAudit
4
+ class VersionProxy
5
+ def initialize(version)
6
+ @version = version
7
+ end
8
+
9
+ def message
10
+ @message = @version.action
11
+ if @message == 'create'
12
+ return 'new'
13
+ end
14
+ if @message == 'destroy'
15
+ return 'delete'
16
+ end
17
+ mods = @version.modified.to_a.map do |c|
18
+ if c[1].class.name == "Moped::BSON::Binary" || c[1].class.name == "BSON::Binary"
19
+ c[0] + " = {binary data}"
20
+ elsif c[1].to_s.length > 220
21
+ c[0] + " = " + c[1].to_s[0..200]
22
+ else
23
+ c[0] + " = " + c[1].to_s
24
+ end
25
+
26
+ end
27
+ @version.respond_to?(:modified) ? @message + ' ' + table + " [" + mods.join(", ") + "]" : @message
28
+ end
29
+
30
+ def created_at
31
+ @version.created_at
32
+ end
33
+
34
+ def table
35
+ @version.association_chain.last['name']
36
+ end
37
+
38
+ def username
39
+ @version.updater.try(:email) || @version.updater
40
+ end
41
+
42
+ def item
43
+ @version.association_chain.last['id']
44
+ end
45
+ end
46
+
47
+ class AuditingAdapter
48
+ COLUMN_MAPPING = {
49
+ :table => 'association_chain.name',
50
+ :username => 'modifier_id',
51
+ :item => 'association_chain.id',
52
+ :created_at => :created_at,
53
+ :message => :action
54
+ }
55
+
56
+ def initialize(controller, version_class = HistoryTracker)
57
+ @controller = controller
58
+ @version_class = version_class.to_s.constantize
59
+ end
60
+
61
+ def latest(include_empty_modifier = false)
62
+ versions = @version_class
63
+ unless include_empty_modifier
64
+ versions.where(:updater_id.exists => true)
65
+ end
66
+ versions = versions.desc(:_id).limit(20)
67
+ versions.map { |version| VersionProxy.new(version) }
68
+ end
69
+
70
+ def delete_object(object, model, user)
71
+ # do nothing
72
+ end
73
+
74
+ def update_object(object, model, user, changes)
75
+ # do nothing
76
+ end
77
+
78
+ def create_object(object, abstract_model, user)
79
+ # do nothing
80
+ end
81
+
82
+ def listing_for_model(model, query, sort, sort_reverse, all, page, per_page = (RailsAdmin::Config.default_items_per_page || 20))
83
+ listing_for_model_or_object(model, nil, query, sort, sort_reverse, all, page, per_page)
84
+ end
85
+
86
+ def listing_for_object(model, object, query, sort, sort_reverse, all, page, per_page = (RailsAdmin::Config.default_items_per_page || 20))
87
+ listing_for_model_or_object(model, object, query, sort, sort_reverse, all, page, per_page)
88
+ end
89
+
90
+ protected
91
+ def listing_for_model_or_object(model, object, query, sort, sort_reverse, all, page, per_page)
92
+ if sort.present?
93
+ sort = COLUMN_MAPPING[sort.to_sym]
94
+ else
95
+ sort = :created_at
96
+ sort_reverse = 'true'
97
+ end
98
+ model_name = model.model.name
99
+ if object
100
+ versions = @version_class.where('association_chain.name' => model.model_name, 'association_chain.id' => object.id)
101
+ else
102
+ versions = @version_class.where('association_chain.name' => model_name)
103
+ end
104
+ versions = versions.order_by([sort, sort_reverse == 'true' ? :desc : :asc])
105
+ unless all
106
+ page = 1 if page.nil?
107
+ versions = versions.send(Kaminari.config.page_method_name, page).per(per_page)
108
+ end
109
+ versions.map { |version| VersionProxy.new(version) }
110
+ end
111
+ end
112
+ end
113
+ end
114
+ end
115
+
116
+ RailsAdmin.add_extension(:mongoid_audit, RailsAdmin::Extensions::MongoidAudit, {
117
+ :auditing => true
118
+ })
119
+