Path: | lib/vestal_versions.rb |
Last Update: | Sun Feb 13 15:42:39 +0000 2011 |
vestal_versions keeps track of updates to ActiveRecord models, leveraging the introduction of dirty attributes in Rails 2.1. By storing only the updated attributes in a serialized column of a single version model, the history is kept DRY and no additional schema changes are necessary.
Author: | Steve Richert |
Copyright: | Copyright (c) 2009 Steve Richert |
License: | MIT License (www.opensource.org/licenses/mit-license.php) |
To enable versioning on a model, simply use the versioned method:
class User < ActiveRecord::Base versioned end user = User.create(:name => "Steve Richert") user.version # => 1 user.update_attribute(:name, "Steve Jobs") user.version # => 2 user.revert_to(1) user.name # => "Steve Richert"
See the versioned documentation for more details.