I am new to Rails / Ruby. I am working on a project where we want to capture snapshots/revisions of the objects when certain operations happen. Its similar to the ho开发者_StackOverfloww the revision control works for the Writeboards in basecamp. Is there any gem which will automate this functionality or some open source project in RoR which we can use as a reference. Cheers.
acts_as_versioned gem may be what you're looking for - http://github.com/technoweenie/acts_as_versioned
An example of how it works from the RDoc:
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'
page.versions.earliest # efficient query to find the first version
page.versions.latest # efficient query to find the most recently created version
We use a gem called acts as versioned to handle multiple versions of our models. It's available on github.
精彩评论