Skip to content
This repository has been archived by the owner on Nov 24, 2020. It is now read-only.

Add receiver_changes to track changes to an object #5

Open
lleger opened this issue Aug 23, 2016 · 0 comments
Open

Add receiver_changes to track changes to an object #5

lleger opened this issue Aug 23, 2016 · 0 comments

Comments

@lleger
Copy link
Member

lleger commented Aug 23, 2016

We should add another JSONB fields called receiver_changes to track the actual changes to the object. I think we could use ActiveModel::Dirty to accomplish this.

There's two areas of difficulty with this:

  1. The changes get wiped once #save is called, so we may have to use #previous_changes
  2. ActiveJob won't serialize a timestamp, so we may have to sanitize that array (perhaps we can add a proc to the config for that)

Here's some README language I wrote before I attempted to add this earlier:

### Metadata

Transcript tracks some metadata about the audit entry. It logs the receiver at the top of the entry to `receiver_serialized`. This is a JSONB column in PostgreSQL, which can be indexed and queried.

The changes to the receiver, via [`ActiveModel::Dirty`](http://api.rubyonrails.org/classes/ActiveModel/Dirty.html) are also recorded in `receiver_changes`. This is also a JSONB column.

This metadata should allow you to reconstruct the object in either the before or after state.
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant