Memoar
Welcome to memoar! A simple versioning gem for ActiveRecord models using a JSON column.
Installation
Add this line to your application's Gemfile:
gem 'memoar'
And then execute:
bundle install
Or install it yourself as:
gem install memoar
Usage
- 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
end
or with limit of recorded changes (default 50):
class Article < ApplicationRecord
track_changes_to :title, :content, limit: 10
end
article.previous_versions
Contributing
Bug reports and pull requests are welcome on GitHub at https://github.com/amigobg/memoar.
License
The gem is available as open source under the terms of the MIT License.