This is a simple Sequel plugin for PaperTrail (with limited functionality).
Conributions are welcome!
- model are able to subscribe on create, update, delete callback
- can be specified whodunnit
- can be specified info_for_paper_trail
- versioning can be disabled or enabled globaly or in block context
- this gem doesn't create a version table
- versions table has a structure as Paper Trail v0.6.x. has
- whodunnit is global
- info_for_paper_trail is global
Add this line to your application's Gemfile:
gem 'sequel_paper_trail'Our usage model:
- separate service uses Sequel + this plugin
- web uses Paper Trail + Rails Admin.
Be sure that you have a proper tables from Paper Trail v0.6.x.
Than you can subscribe a model on create, update, destroy callbacks.
Quick start:
require 'sequel_paper_trail'
require 'sequel'
require 'sequel/plugins/has_paper_trail'
Album.pligin :has_paper_trail,
class_name: 'VersionClassName'
# or
Album.pligin :has_paper_trail,
item_class_name: SomeAlbum,
class_name: 'VersionClassName'Enable versioning globaly:
SequelPaperTrail.enabled = trueEnable versioning for block of code:
SequelPaperTrail.with_versioning { 'code' }Disable versioning globaly:
SequelPaperTrail.enabled = falseDisable versioning for block of code
SequelPaperTrail.with_versioning(false) { 'code' }Set whodunnit:
SequelPaperTrail.whodunnit = 'Mr. Smith'Set info_for_paper_trail - additional info (Hash) which will be attached to versions table.
# If you have 'release' and 'instance' columns in a versions table you can populate them.
SequelPaperTrail.info_for_paper_trail = { release: 'asdf131234', instance: `hostname` }After checking out the repo, run bin/setup to install dependencies. Then, run rake spec to run the tests. You can also run bin/console for an interactive prompt that will allow you to experiment.
To install this gem onto your local machine, run bundle exec rake install. To release a new version, update the version number in version.rb, and then run bundle exec rake release, which will create a git tag for the version, push git commits and tags, and push the .gem file to rubygems.org.
This gem has a very limited functionality so conributions are welcome!
Bug reports and pull requests are welcome on GitHub at https://github.com/lazebny/sequel_paper_trail.
The gem is available as open source under the terms of the MIT License.
