Re: Re: implement audit trail table

Rick Olson
Tue, 26 Jul 2005 19:20:03 -0000

On 7/26/05, Michael Schuerig
<michael-q5aiKMLteq4b1SvskN2V4Q@public.gmane.org>
wrote:
> On Tuesday 26 July 2005 04:14, Rick Olson wrote:
> > I am working on such a mod: http://dev.rubyonrails.org/ticket/1758
>
> I''ve only looked at it cursorily. Do you intend to implement
versioning
> for habtm associations, too?
>
> Michael


I don''t think versioning that would be very interesting really.  habtm
tables usually don''t even have keys, so are rarely updated.  Now, if
you have a @developer and you want to version it''s projects, you could
use a before_save that serialized the project info to a text column
and version that.

Taking that approach further, I could add an option like so:

class Developer < AR::Base
  habtm :projects
  acts_as_versioned :serialize => [ :projects ]
end

It could create a virtual versioned_projects attribute in your model
and save it to an actual versioned_projects field in the versions
table in before_save.

Thoughts?

--
rick