2010-09-23 77 views
3

我是Rails/Ruby的新手。我正在研究一个项目,我们希望在某些操作发生时捕获对象的快照/修订。它类似于版本控制如何在basecamp中为Writeboards工作。有没有任何可以自动执行此功能的宝石或RoR中的一些开放源码项目,我们可以将它们用作参考。干杯。Rails中的模型版本控制

回答

4

acts_as_versioned宝石可能是你在找什么 - http://github.com/technoweenie/acts_as_versioned

它从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 
+0

就是我在找的东西。干杯。 – Barry 2010-09-23 13:43:18

1

我们使用一个名为acts as versioned来处理我们的模型的多个版本的宝石。它在github上可用。