I want to add custom attributes in the Audit Log like first_name, last_name using audited gem. Any idea how I can update the values of my custom attributes ?
#<AuditLog id: 1,
auditable_id: 2,
auditable_type: "User",
associated_id: nil,
associated_type: nil,
user_id: 2,
company_id: nil,
user_type: "User",
username: nil,
first_name: nil, last_name: nil, action: "update",
audited_changes: {"first_name"=>["Name1", "Name2"]}, version: 8,
comment: nil,
remote_address: "::1", request_uuid: "ed24f0d3-7ca7-42b1-b1a4-202222b38f7c", created_at: "2022-01-28 17:59:08">
enter code here
My user model contains these two attributes
t.column :first_name, :string
t.column :last_name, :string
It should just work. The audit record doesn't store discrete fields, it stores a YAML or jsonb representation of all changed fields. If you've added first_name to your users table, the audit record will automatically note any changes to that attribute.