Path: | README |
Last Update: | Sun Dec 30 11:51:41 +0000 2007 |
SimplyVersioned
Release: 0.2 Date: 30-12-2007 Author: Matt Mower <self@mattmower.com>
SimplyVersioned is a simple, non-invasive, approach to versioning ActiveRecord models.
SimplyVersioned does not require any structural change to the models to be versioned and requires only one versions table to be created (a migration generator is supplied with the plugin) regardless of the number of models being versioned.
The plugin introduces a ‘Version’ ActiveRecord model (that reflects changes to model attributes) to which versioned models are polymorphically associated. Version records store the model information as a YAML hash.
SimplyVersioned meets a simple need for model versioning. If your needs are more complex maybe try Rick Olsen‘s acts_as_versioned (svn.techno-weenie.net/projects/plugins/acts_as_versioned/).
SimplyVersioned has (so far) been tested and found to work with Rails 2.0.1 and Ruby 1.8.6p111.
Usage
./script/plugin install http://rubymatt.rubyforge.org/svn/simply_versioned
./script/generate simply_versioned_migration
rake db:migrate
class Thing < ActiveRecord::Base simply_versioned :keep => 10 end
thing = Thing.create!( :foo => bar ) # creates v1 thing.foo = baz thing.save! # creates v2
thing.versions.each do |version| ... end render :partial => 'thing_version', :collection => thing.versions thing.versions.current thing.versions.first thing.versions.get( 3 )
thing.revert_to_version( 5 )
thing.versions.current.previous thing.versions.first.next
thing.versions.first.model # => Instantiated Thing with versioned values
Copyright (c) 2007 Matt Mower <self@mattmower.com> and released under the MIT license