acts_as_versioned_with_changes
Acts As Versioned is a very cool gem from technoweenie that will store versioned copies of your main table in a secondary _versions table. One problem I noticed in trying to get it running was that running sudo gem install acts_as_versioned grabbed what appeared to be a very old copy which failed miserably with Rails 2.3 due to the older version not being compatible with the new ‘dirty’ object functionality added in Rails 2.1, so I found I had to clone it from the github repo: http://github.com/technoweenie/acts_as_versioned.
I was quoting on a project that required a log of changes made from version to version, so I forked the gem and made some modifications…. My fork takes advantage of the aforementioned ‘dirty’ object feature to create a serialized ‘changes’ column, so when you are working with a version you also have access to a version.changes hash which you can use to do something like this:
<% version.changes.each_pair do |key,values| %>
Field: <%= key >
Original: <%= values.first %>
Updated: <%= value.last %>
<% end %>
Get it here: git clone git://github.com/gordonbisnor/acts_as_versioned_with_changes.git
I am available for Ruby on Rails consulting work – get in touch to learn more.