| Module | ActiveRecord::Acts::Versioned |
| In: |
lib/acts_as_versioned.rb
|
Specify this act if you want to save a copy of the row in a versioned table. This assumes there is a versioned table ready and that your model has a version field. This works with optimisic locking if the lock_version column is present as well.
class Page < ActiveRecord::Base
# assumes pages_versions table
acts_as_versioned
end
Example:
page = Page.create(:title => 'hello world!') page.version # => 1 page.title = 'hello world' page.save page.version # => 2 page.versions.size # => 2 page.revert_to(1) # using version number page.title # => 'hello world!' page.revert_to(page.versions.last) # using versioned instance page.title # => 'hello world'
See ActiveRecord::Acts::Versioned::ClassMethods#acts_as_versioned for configuration options