Search code examples
ruby-on-railsrubyacts-as-audited

how to get the difference between old value and new value in ruby


I'm using acts_as_audited gem in Ruby it works fine. When I created, updated or deleted the model, it capture the changes into an audits table. When updating models it shows the old value and new value in single column in audits table. For example:

1|2|Student||||||update|---
age:
- 8
- 11
|3||122.174.107.161|2012-03-20 08:56:42.951459
2|3|Student||||||update|---
name:
- Simon
- Simson
age:
- 12
- 21
department:
- Civil
- Physics
|2||122.174.107.161|2012-03-20 08:57:12.631156

How to observe new value and old value in two separate column in audits table.


Solution

  • I can't help with this gem, but looks like paper trail does this by default:

    https://github.com/airblade/paper_trail

    http://railscasts.com/episodes/255-undo-with-paper-trail