Module: RailsAuditLog::Controller

Extended by:
ActiveSupport::Concern
Defined in:
app/concerns/rails_audit_log/controller.rb

Overview

Include in ApplicationController (or any controller) to automatically set and clear the current actor for every request, so that audit entries written during the request are tagged with the signed-in user.

Usage

class ApplicationController < ActionController::Base
  include RailsAuditLog::Controller
  audit_log_actor { current_user }
end

The block passed to audit_log_actor is evaluated in controller instance context on every request via a before_action. The actor is cleared in an after_action so it never leaks between requests.

Request metadata (remote_ip, user_agent) is captured automatically when #capture_request_metadata is true.