Looking for readable list of audits
Hi all, is there an easy implementation to translate the audits to a readable json array to show in the UI?
lol I just came to the issues section to ask this same question
We can get the desired output by using the following code snippet
Audited::Audit.all.as_json
or Alternatively, you can define a controller like
class AuditsController < ApplicationController
def index
@audits = Audited::Audit.all
render json: {
data: @audits.to_a,
message: "Audits listed successfully"
}
end
end
which will return data as
"data": [ { "id": 1, "auditable_id": 1, "auditable_type": "Task", "associated_id": null, "associated_type": null, "user_id": null, "user_type": null, "username": null, "action": "update", "audited_changes": { "status": [ "draft", "deleted" ] }, "version": 1, "comment": null, "remote_address": null, "request_uuid": "a657f26c-1620-4ffe-8e9b-5e70def0ad28", "created_at": "2021-02-26T11:42:57.682Z" }]
For more reference you can check Audited-Example