Audit tables?

Hi,

I would like to create audit tables in my RoR/mysql app. I would like
to
start out auditing just about everything: every change in the database
should result in a row in (one or more) audit tables. My app requires
login, so I would like to include the user_id in all entries.

Is there a good starting point for this or should I simply design the
table(s), build triggers, etc.?

Thanks,

Marc

On 8/30/07, Marc B. [email protected] wrote:

Hi,

I would like to create audit tables in my RoR/mysql app. I would like to
start out auditing just about everything: every change in the database
should result in a row in (one or more) audit tables. My app requires
login, so I would like to include the user_id in all entries.

Is there a good starting point for this or should I simply design the
table(s), build triggers, etc.?

You need to learn about AR’s callbacks
(ActiveRecord::Callbacks),
which are “hooks” where you can add the auditing code.

Also, google for “rails created_by” for some articles related to the
issue of getting the user id. It’s not as easy as it looks, because
the model code (where the callbacks are) doesn’t really have access to
the controller (where the user id is). It can be done (I’m doing it),
but you need to read up on the various considerations, especially
thread-safety.

HTH

There is this plugin I found from a google search. I’ve not used it,
but check it out and see if it’s what you need.

http://opensoul.org/2006/7/21/acts_as_audited

I have a similar requirement as I’m working on a database system for
clinical trials. I’ve investigated the plugins mentioned but I wasn’t
too comfortable for many reasons, especially with the ability to
reconstruct from audit trail.

I’m actually looking into extending the ActiveRecord.

Joon You wrote:

I have a similar requirement as I’m working on a database system for
clinical trials. I’ve investigated the plugins mentioned but I wasn’t
too comfortable for many reasons, especially with the ability to
reconstruct from audit trail.

I’m actually looking into extending the ActiveRecord.

Observers are the way to go if you require this kind of functionality

I would like to create audit tables in my RoR/mysql app. I would like to
start out auditing just about everything: every change in the database
should result in a row in (one or more) audit tables. My app requires
login, so I would like to include the user_id in all entries.

Is there a good starting point for this or should I simply design the
table(s), build triggers, etc.?

http://agilewebdevelopment.com/plugins/search?search=audit