# Session data in observer

**URL:** <https://www.ruby-forum.com/t/session-data-in-observer/118890>\
**Category:** Rails\
**Created:** [November 1, 2007, 1:51am UTC](https://www.ruby-forum.com/t/session-data-in-observer/118890 "2007-11-01T01:51:14Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![da991319](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/ebca7d/32.png) [@da991319](https://www.ruby-forum.com/u/da991319)\
**Post date:** [November 1, 2007, 1:51am UTC](https://www.ruby-forum.com/t/session-data-in-observer/118890/1 "2007-11-01T01:51:14Z")

</div>

Hello,

In my app, there is an observer that gets fired when an change is done  
on one table. what i want it to do is to write into an other table the  
action done and the user which made the action.

But until now i didn’t manage to get the session data into the  
observer. I always get “session, undefined methode for observer”

Any ideas how i can handle this?

thank you

---

<div class="post-metadata">

**Author:** ![da991319](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/ebca7d/32.png) [@da991319](https://www.ruby-forum.com/u/da991319)\
**Post date:** [November 1, 2007, 2:39am UTC](https://www.ruby-forum.com/t/session-data-in-observer/118890/2 "2007-11-01T02:39:08Z")

</div>

Observers, like models, are not meant to have access to the session.  
It’s a  
violation of the MVC pattern.

You’re not really supposed to be doing what you’re doing. It does make  
doing  
auditing a bit harder. However, the Rails Recipes book shows how you can  
hack cache\_sweepers to do what you’re trying to do.

---

<div class="post-metadata">

**Author:** ![da991319](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/ebca7d/32.png) [@da991319](https://www.ruby-forum.com/u/da991319)\
**Post date:** [November 2, 2007, 2:30am UTC](https://www.ruby-forum.com/t/session-data-in-observer/118890/3 "2007-11-02T02:30:40Z")

</div>

Hello thank you i will try to have a look to the receipe book. but i  
also think about using a filter before just to respect the MVC  
pattern.  
Thank you
