Re: implement audit trail table

Rick Olson
Tue, 26 Jul 2005 02:14:56 -0000

On 7/25/05, Paul Chin <paulchin-0SqPFV7GnR3FK4RKhr3rmg@public.gmane.org>
wrote:
> has anyone has any idea how to implement audit trail table for all update /
> deletion done on records?
>
> I''m thinking to have corresponding audit trail table to each
table, so
> everthing before an update or deletion is done, a new record will be insert
> into the corresponding audit trail table.
>
> Is there a way to overwrite the save, destroy, method at the application
> level? so that I do not need to overwrite it in every model file?

I am working on such a mod:  http://dev.rubyonrails.org/ticket/1758

You can override save/destroy, at the ActiveRecord::Base class, but
it''s probably better to use callbacks.  With the acts_as_versioned
method, just do this:

class Post < AR::Base
  acts_as_versioned
end

I have a simple method for a migration to create the versioned table also.

--
rick