Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

Already on GitHub? Sign in to your account

interaction with acts_as_audited causes stack level too deep #253

dgm opened this Issue May 6, 2011 · 1 comment


None yet
1 participant

dgm commented May 6, 2011

also reported here: https://github.com/collectiveidea/acts_as_audited/issues/21

When I try to use the last_request_at column with acts_as_audited enabled, I get one good request after a server restart, and then after that all requests fail with a stack level too deep error.

At this point, I don't even get a good stack trace, all I get is:

SystemStackError (stack level too deep):

dgm commented Jul 10, 2011

I discovered a loop in the way current_user and current_user_session interact with the auditing code. It appears that last_request_at is updated for every UserSession.find call, which is done during a current_user call. This update triggers the audit code, which also calls current user, which looks for the session... infinite loop. My temporary fix is to change my application controller code to:

    def current_user
      return @current_user if defined?(@current_user)
      User.without_auditing do
        @current_user = current_user_session && current_user_session.user

On a slightly related note, I notice now that updated_at updates with last_request_at ... which seems redundant, and hurts the usefulness of that column. I wonder if when setting last_request_At, if we use an update method that bypasses callbacks and validations, if that would solve both issues at once.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment