Peter Marklund

Peter Marklund's Home

Sat Aug 11 2007 06:11:11 GMT+0000 (Coordinated Universal Time)

Rails Deployment: Looking up User ID from a Session ID

Suppose you get an exception notification and you want to know which user was browsing the site when the exception occured. The exception email has the HTTP_COOKIE header with the _session_id. Assuming you are using ActiveRecordStore and that you store the user ID in the session, you can look it up with an incantation like the following:


I keep forgetting the module path to the Session class so I thought I'd post this note. The corresponding Rails file is active_record_store.rb in ActionPack.