store attribute metadata as it exists at creation, instead of nil#458
Conversation
|
As discussed in some previous issues (#185, #385, #387), this is the expected behavior, as all of the aspects of a model (including metadata) are meant to show what the model looked like PRIOR to the event driving the generation of the version. That being said, I'm guessing that lots of users (I've done this in the past as well) are often looking to have the metadata populated even on Although it begs the question: How important are |
|
For me the value of create events is to have a complete history available in paper trail without having to reify anything or check existing objects. If you don't store create events the only way to get the date a model was created is to check created_at on an existing model or reify a version for deleted models. This method also only works if your model has a created_at attribute, which isn't a given. |
store attribute metadata as it exists at creation
|
Cheers |
|
Isn't this a significant mismatch in behavior for new records vs update records? When metadata may be nil for created records, this matches the It seems like this behavior breaks a few possible expectations:
Would a new issue be better for discussion, or has this already been hashed out? |
|
These all seem like valid concerns, @Billiam. Ben, can address these concerns? |
When the initial paper trail version is created any attribute metadata will be nil instead of the values that exist, because #{attribute}_was will always return nil for new models. This looks like an explicit decision, given there is a test, but I don't understand the logic behind it.
For background, in my case I'm building a multi-tenant application and I'm adding the tenant id attribute to my paper trail version metadata. It's important for us to be able to query the version history restricted by tenant, and with the current behavior it's impossible to match create events with a tenant without reifying the actual objects.
Any other use case for storing attribute metadata I can think of also would benefit from storing the metadata that exists at create, rather than storing nil, but maybe I'm missing something?