Casecommons / pg_audit_log

Create a trigger-based audit log for PostgreSQL
MIT License
3 stars 2 forks source link

setting current user #6

Closed treseder closed 9 years ago

treseder commented 11 years ago

I couldn't find any kind of dev mailing list for this great gem, so I'm asking this question, here.

I need to store the current user in the audit table. I've looked through the pg_audit_log code and it looks like it expects to find the user identifier in the current thread:

current_user = Thread.current[:current_user]

It seems, then, that the best way to log the user in the audit table is to set the user in the Thread.current hash for each request, like in an around controller filter. Is that correct? Or, am I missing something?

amarshall commented 9 years ago

Yes, that’s correct, though I’m considering changing exactly how this happens sometime in the future.