ruby
9 lines · 1 tab
Kai Nakamura
Apr 2026
1 tab
AuditLog.create!(
actor_id: current_user.id,
action: 'member.approve',
target_type: 'Member',
target_id: member.id,
ip_address: request.remote_ip,
user_agent: request.user_agent,
metadata: { previous_status: member.status, new_status: 'approved' },
)
1 file · ruby
Explain with highlit
Security-relevant actions need durable, queryable audit trails. I log actor, action, target, request context, and result in a structured format that can feed SIEM pipelines directly. Good audit logs help with investigations and deterrence; vague logs do neither.
Share this code
Here's the card — post it anywhere.