MongoidAudit 1.0 is a complete rewrite and might break backwards compatibility
Since 1.0.0, mongoid_audit is no longer a fork, but a wrapper of mongoid-history, providing out-of-the-box Userstamp, RailsAdmin integration and easier setup and configuration.
-
delete the initializer (if you had default settings).
-
replace
include Mongoid::Audit::Trackable
track_history track_create: true, track_destroy: true
With:
include Trackable
-
Database storage format for user / modifier in 1.0.0 was changed, since now glebtv_mongoid_userstamp gem is used to store modifier. To migrate your data you should do something like:
HistoryTracker.all.each{|ht| ht.rename(modifier_id: :updater_id)}
-
This gem includes storing modifier, but it is done via
glebtv_mongoid_userstamp
and not directly. -
RailsAdmin auditing adapter is still fully supported.
Add this line to your application's Gemfile:
# must be after rails_admin, if you use it
gem 'mongoid-audit', '~> 1.0.0'
And then execute:
$ bundle
Or install it yourself as:
$ gem install mongoid-audit
Include Trackable
in your models. That's it, you are done!
include Trackable
Identical to Mongoid::History. See https://github.com/aq1018/mongoid-history
include Mongoid::History::Trackable
include Mongoid::Userstamp
track_history({
track_create: true,
track_destroy: true,
track_update: true,
modifier_field: :updater,
except: ["created_at", "updated_at", "c_at", "u_at", "clicks", "impressions", "some_other_your_field"],
})
Add to an initializer:
Mongoid::History.modifier_class_name = 'Author'
Mongoid::Userstamp.config do |c|
c.user_reader = :current_admin
c.user_model = :admin
end
Add
config.audit_with :mongoid_audit
in config/initializers/rails_admin.rb
(c) 2013-2014 http://rocketscience.pro MIT License.
- Fork it
- Create your feature branch (
git checkout -b my-new-feature
) - Commit your changes (
git commit -am 'Add some feature'
) - Push to the branch (
git push origin my-new-feature
) - Create new Pull Request