# Authlogic::How to access current user from within a cache sweeper?

**URL:** <https://www.ruby-forum.com/t/authlogic-how-to-access-current-user-from-within-a-cache-sweeper/173152>\
**Category:** Rails\
**Created:** [August 4, 2009, 5:07am UTC](https://www.ruby-forum.com/t/authlogic-how-to-access-current-user-from-within-a-cache-sweeper/173152 "2009-08-04T05:07:41Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![coolmenu](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/eada6e/32.png) [@coolmenu](https://www.ruby-forum.com/u/coolmenu)\
**Post date:** [August 4, 2009, 5:07am UTC](https://www.ruby-forum.com/t/authlogic-how-to-access-current-user-from-within-a-cache-sweeper/173152/1 "2009-08-04T05:07:41Z")

</div>

So I’m trying to follow along in Chad F.'s Rails Recipes (recipe  
#59, Keeping track of who did what) and I simply want to access the  
current user from within my cache sweeper. Normally you just  
reference @current\_user but that doesn’t seem to be the case here.

In Chad’s example, he calls controller.session[:user]. What’s the  
Authlogic equivalent? Thanks for any help.

Here is Chad’s full example:

class AuditSweeper \< ActionController::Caching::Sweeper  
observe Person

def after\_destroy(record)  
log(record, “DESTROY” )  
end

def log(record, event, user = controller.session[:user])  
AuditTrail.create(:record\_id =\> record.id, :record\_type =\>  
record.type.name, :event =\> event, :user\_id =\> user)  
end

end
