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