# Creating log of changes to active record objects

**URL:** <https://www.ruby-forum.com/t/creating-log-of-changes-to-active-record-objects/123781>\
**Category:** Rails\
**Created:** [December 20, 2007, 4:28pm UTC](https://www.ruby-forum.com/t/creating-log-of-changes-to-active-record-objects/123781 "2007-12-20T16:28:09Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![kturner](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/k/c2a13f/32.png) [@kturner](https://www.ruby-forum.com/u/kturner)\
**Post date:** [December 20, 2007, 4:28pm UTC](https://www.ruby-forum.com/t/creating-log-of-changes-to-active-record-objects/123781/1 "2007-12-20T16:28:09Z")

</div>

Hi,

My client wants something to track actions on objects. For instance, if  
one of his employees makes an edit to the system, he wants a log of what  
happened. I started adding the after\_create, after\_update,  
after\_destroy observer callbacks to the objects that he wants this for.  
They create a ‘sitetransaction’ object (I use the term transaction  
loosly, because this isn’t the same as a database transaction) which  
will log what object was created/updated/deleted, who do this, and when.  
Pretty simple stuff.

The issue is with the “who did this” part. I have the user name stored  
in a session variable. I can’t access the session data in the model.  
Any thoughts on how I can access the session data, or how I can  
accomplish this in a better way?

Regards,  
Kevin

---

<div class="post-metadata">

**Author:** ![kturner](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/k/c2a13f/32.png) [@kturner](https://www.ruby-forum.com/u/kturner)\
**Post date:** [December 20, 2007, 8:57pm UTC](https://www.ruby-forum.com/t/creating-log-of-changes-to-active-record-objects/123781/2 "2007-12-20T20:57:11Z")

</div>

Perhaps you’re looking for something like acts\_as\_audited?

On Dec 21, 2007 1:58 AM, Kevin T.  
[removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)  
wrote:

> Pretty simple stuff.
> 
> >

–  
Ryan B.

> **[frozenplague.net](http://www.frozenplague.net)**
>
> This domain may be for sale!

---

<div class="post-metadata">

**Author:** ![kturner](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/k/c2a13f/32.png) [@kturner](https://www.ruby-forum.com/u/kturner)\
**Post date:** [December 20, 2007, 9:07pm UTC](https://www.ruby-forum.com/t/creating-log-of-changes-to-active-record-objects/123781/3 "2007-12-20T21:07:29Z")

</div>

That’s exactly what I need. Thanks for the link!

Ryan B. wrote:

> Perhaps you’re looking for something like acts\_as\_audited?
> 
> On Dec 21, 2007 1:58 AM, Kevin T.  
> [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)  
> wrote:
> 
> > Pretty simple stuff.
> > 
> > >
> 
> –  
> Ryan B.  
> [http://www.frozenplague.net](http://www.frozenplague.net)
