Hansel is tiny library that tracks change to followed models, has support for both syncronous tracking and asynchronous via the different ActiveJob backends that you can plug into your Rails application. Currently only supports for PostgreSQL databases.
Import the concern in the models that you wish to track
class Human < ApplicationRecord
include Hansel::Recordable
endAnd after every change to an Human record you can access its states through the has_many :records relationship - e.g. Human.first.records # []
Add this line to your application's Gemfile:
gem 'hansel'And then execute:
$ bundle installGenerate schema migration:
$ rails generate hansel:installMigrate your database:
$ rails db:migrateThe gem is available as open source under the terms of the MIT License.