Here’s a simple audit logging solution using an AuditLog ActiveRecord model with a polymorphic association, a Sidekiq worker, and an audit_log controller method. I wrote about the approach in Audit Logging in Rails.
AuditLog
audit_log
class ApplicationController < ActionController::Base def audit_log(auditable, account, event) AuditLogWorker.perform_async(auditable.to_global_id, account.id, current_user.id, event) end end
The audit_log method can be called from any controller action to log events for any auditable model.