Trail audit logs (Operation logs) into the database for user behaviors, including a web UI to query logs.
Add this line to your application's Gemfile:
gem 'audit-log'
And then execute:
$ bundle
Generate files:
$ rails g audit_log:install
Use in controllers:
class TicktsController < ApplicationController
def index
audit! :tickets, nil
end
def update
audit! :update_ticket, @ticket, payload: ticket_params
end
def destroy
audit! :delete_ticket
end
private
def ticket_params
params.required(:ticket).permit!(:title, :description, :status)
end
end
In models or other places:
AuditLog.audit!(:update_password, @user, payload: { ip: request.ip })
AuditLog.audit!(:sign_in, @user, payload: { ip: request.ip })
AuditLog.audit!(:create_address, nil, payload: params)
The gem is available as open source under the terms of the MIT License.