Here is an example and why its kinda sucks:
model = Model.first
version = model.versions[0]
record = JSON.parse(version.to_json).except("id") #It turns ActiveRecord to a hash
#we might need this record above to sync to some other database
version.created_at == record["created_at"] # returns FALSE!! although
#they both have the same string value, and case persists
#even if you turn them into the same class with same values (strange)
#why it is important? here is why:
PaperTrail::Version.find_or_create_by(record)
#This would create a new record... very strange given it just duplicates the first
# create event trail. This weird behavior makes syncing to databases via script kinda hacky
#I need to do the following to prevent duplication for the new database:
record = record.except("created_at") if record["event"] == "create"
PaperTrail::Version.find_or_create_by(record)
#update events don't create this duplication I don't know the situation for the delete event trails
Here is an example and why its kinda sucks: