Welcome to memoar! A simple versioning gem for ActiveRecord models using a JSON column.
Add this line to your application's Gemfile:
gem 'memoar'And then execute:
bundle installOr install it yourself as:
gem install memoar- Generate a migration to add the version_log column to your model:
rails generate memoar:install ModelName- Run the migration:
rails db:migrate- In your ActiveRecord model, specify fields to track:
class Article < ApplicationRecord
track_changes_to :title, :content
endor with limit of recorded changes (default 50):
class Article < ApplicationRecord
track_changes_to :title, :content, limit: 10
endarticle.previous_versionsBug reports and pull requests are welcome on GitHub at https://github.com/amigobg/memoar.
The gem is available as open source under the terms of the MIT License.