# Diffing tables using acts\_as\_versioned

**URL:** <https://www.ruby-forum.com/t/diffing-tables-using-acts-as-versioned/112053>\
**Category:** Rails\
**Created:** [August 14, 2007, 6:40pm UTC](https://www.ruby-forum.com/t/diffing-tables-using-acts-as-versioned/112053 "2007-08-14T18:40:37Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![rubylover](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/8c91f0/32.png) [@rubylover](https://www.ruby-forum.com/u/rubylover)\
**Post date:** [August 14, 2007, 6:40pm UTC](https://www.ruby-forum.com/t/diffing-tables-using-acts-as-versioned/112053/1 "2007-08-14T18:40:37Z")

</div>

I’m looking for a solution to read and store the differences between  
two updates to a row in my DB.

For example, if a user changes the number of hours they worked after  
submitting their timesheet, I want to be able to show a manager the  
change they made and then report that adjustment.

> From looking at the docs, acts\_as\_versioned works for versioning a  
> model and then stepping through previous revisions, but there doesn’t  
> seem to be a way to compare the differences between two revisions. Am  
> I wrong in that assumption? If so, can someone point me to the docs I  
> should be looking at.

If I’m not wrong, is there another plugin available or does anyone  
have any suggestions for how to go about implementing a versioning  
system in the way I’m looking for.

Thanks.

---

<div class="post-metadata">

**Author:** ![rubylover](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/8c91f0/32.png) [@rubylover](https://www.ruby-forum.com/u/rubylover)\
**Post date:** [August 14, 2007, 9:37pm UTC](https://www.ruby-forum.com/t/diffing-tables-using-acts-as-versioned/112053/2 "2007-08-14T21:37:00Z")

</div>

On 8/14/07, Justin W. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> seem to be a way to compare the differences between two revisions. Am  
> I wrong in that assumption? If so, can someone point me to the docs I  
> should be looking at.
> 
> If I’m not wrong, is there another plugin available or does anyone  
> have any suggestions for how to go about implementing a versioning  
> system in the way I’m looking for.

I’ve been using the riff plugin with Lighthouse.

[http://tfletcher.com/svn/rails-plugins/riff/](http://tfletcher.com/svn/rails-plugins/riff/)

It helps to store a serialized hash of the diffs in the version model  
too, otherwise you have to recalculate each time the view is rendered.

–  
Rick O.  
[http://lighthouseapp.com](http://lighthouseapp.com)  
[http://weblog.techno-weenie.net](http://weblog.techno-weenie.net)  
[http://mephistoblog.com](http://mephistoblog.com)

---

<div class="post-metadata">

**Author:** ![rubylover](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/8c91f0/32.png) [@rubylover](https://www.ruby-forum.com/u/rubylover)\
**Post date:** [August 16, 2007, 2:46am UTC](https://www.ruby-forum.com/t/diffing-tables-using-acts-as-versioned/112053/3 "2007-08-16T02:46:43Z")

</div>

On Aug 14, 2:35 pm, “Rick O.” [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> I’ve been using the riff plugin with Lighthouse.
> 
> [http://tfletcher.com/svn/rails-plugins/riff/](http://tfletcher.com/svn/rails-plugins/riff/)
> 
> It helps to store a serialized hash of the diffs in the version model  
> too, otherwise you have to recalculate each time the view is rendered.

Awesome plugin suggestion, Rick. Thanks for pointing it out.

- j

---

<div class="post-metadata">

**Author:** ![rubylover](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/8c91f0/32.png) [@rubylover](https://www.ruby-forum.com/u/rubylover)\
**Post date:** [August 16, 2007, 2:54am UTC](https://www.ruby-forum.com/t/diffing-tables-using-acts-as-versioned/112053/4 "2007-08-16T02:54:47Z")

</div>

Justin W. wrote:

> I’m looking for a solution to read and store the differences between  
> two updates to a row in my DB.

> **[acts\_as\_audited](https://opensoul.org/2006/07/21/acts_as_audited/)**
>
> NOTE: This article is out of date. Visit the project on Github or the mailing list for up-to-date information.

Great for logs or versioning (which was recently added).

Much more efficient than acts\_as\_versioned.
