# Logging stuff

**URL:** <https://www.ruby-forum.com/t/logging-stuff/159278>\
**Category:** Rails\
**Created:** [February 2, 2009, 11:53pm UTC](https://www.ruby-forum.com/t/logging-stuff/159278 "2009-02-02T23:53:45Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![deadinplastic](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/d2c977/32.png) [@deadinplastic](https://www.ruby-forum.com/u/deadinplastic)\
**Post date:** [February 2, 2009, 11:53pm UTC](https://www.ruby-forum.com/t/logging-stuff/159278/1 "2009-02-02T23:53:45Z")

</div>

Say I wanted to log all successful and failed saves to a special log  
table. But I also wanted to save the logged in user and some other  
session stuff.  
I assume I would have some sort of module included into the controllers,  
which would then do something with the methods of the objects being  
manipulated, but I’m not sure what the best approach is. I’ve tried a  
few variations of alias\_method, but I’m struggling to get the  
information from the controller across to the context of the model.  
Does the answer involve binding perhaps?

---

<div class="post-metadata">

**Author:** ![deadinplastic](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/d2c977/32.png) [@deadinplastic](https://www.ruby-forum.com/u/deadinplastic)\
**Post date:** [February 3, 2009, 12:38am UTC](https://www.ruby-forum.com/t/logging-stuff/159278/2 "2009-02-03T00:38:57Z")

</div>

Use acts\_as\_audited.

---

<div class="post-metadata">

**Author:** ![deadinplastic](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/d2c977/32.png) [@deadinplastic](https://www.ruby-forum.com/u/deadinplastic)\
**Post date:** [February 3, 2009, 12:38am UTC](https://www.ruby-forum.com/t/logging-stuff/159278/3 "2009-02-03T00:38:57Z")

</div>

> Say I wanted to log all successful and failed saves to a special log  
> table. But I also wanted to save the logged in user and some other  
> session stuff.  
> I assume I would have some sort of module included into the  
> controllers,  
> which would then do something with the methods of the objects being  
> manipulated, but I’m not sure what the best approach is. I’ve tried a  
> few variations of alias\_method, but I’m struggling to get the  
> information from the controller across to the context of the model.  
> Does the answer involve binding perhaps?

This is what I did on a recent project…

[http://pjkh.com/articles/2009/02/02/creating-an-audit-log-in-rails](http://pjkh.com/articles/2009/02/02/creating-an-audit-log-in-rails)

-philip
