Data Audit
For some tables, we audit each record. So the system will record the change data Example: https://hungryhub.com/admin/reservations/1985035/audit_data
"channel": [
0, # first item is the first data
10 # the changed data (or the existing data)
],
"ack": [
false, # the first data
true # the changed data (or the existing data)
],
"note": null, # if show like this because the first value was null on DB
"cancel_url": null, # if show like this because the first value was null on DB
"gcal_id": null, # if show like this because the first value was null on DB
"remindered": false, # if show like this because the first value was null on DB
"deleted_at": null, # if show like this because the first value was null on DB
"kids": 0, # if show like this because the first value was null on DB
"adult": 3, # if show like this because the first value was null on DB
"adjusted": false, # if show like this because the first value was null on DB
"group_booking": false, # if show like this because the first value was null on DB
"created_by": [
null, # the first data
"user" # the changed data (or the existing data)
],
for this feature we use https://github.com/collectiveidea/audited gem. example :
reservation = Reservation.last
reservation.date = Date.tomorrow
reservation.save
when method save is executed, the audit gem will log changes to the date data
If a reservation is updated 10 times, then there will be 10 data changes, the way to check it is in the reservation.audits method
The audited gem also records who updated the data, for example:
{
"id": 12317694,
"auditable_id": 1985035,
"auditable_type": "Reservation",
"associated_id": null,
"associated_type": null,
"user_id": 355947,
"user_type": "User",
"username": null,
key user_type dan user_id, it means User.find(355947)