I’m trying to use acts_as_versioned together with activerecord-diff
plugin. I have a Testcase model which is versioned.
class Testcase < ActiveRecord::Base
diff :exclude => [:updated_at, :version, :id]
In my view, I’d like to show a summary of changes.
So I tried following code in the show.html.erb:
last_version = nil
@testcase.versions.each do |version|
But when I try to enter the page, I got following error:
NoMethodError in Testcases#show
Showing /home/lukas/Aptana Studio 3 Workspace/testup/app/views/
testcases/show.html.erb where line #13 raised:
undefined method `diff’ for #Testcase::Version:0x7f49b65c5c90
Extracted source (around line #13):
10: <% else %>
12: changes = 
13: differences = version.diff(last_version)
14: differences.each do |field, d|
15: #next if ignored_fields.include?(field)
16: new_value, old_value = *d
Seems that the activerecord-diff is not allowed for the versions of
Testcase, only for testcase itself. But since the versions are managed
automatically by acts_as_versioned, I do not know how to tell
activerecord-diff to work with it.
Can you help me?
(The only solution I found so far is to manually create temporal
Testcase from version object and use diff on that one, but there must
be a better way)
Thanks in advance