Reputation: 101
Using Airblade's PaperTrail gem, I need to track changes to a particular model for all columns, but then I need to filter selectively to see changes for just one particular column. To make it more concrete, if I have a File
model that has a label
attribute/column and I want to display the label history, all I can get right now is all version history for the file, which will include non-label updates to other attributes. (Furthermore, I don't just need the label update itself, but also the whodunnit
and created_at
associated with that version.)
I don't see anything in the documentation to do this - the closest I've come is adding metadata, which allows me to more easily access the information for this attribute, but doesn't return a filtered collection of the pertinent version history.
Upvotes: 2
Views: 639
Reputation: 101
Answer: anywhere that you update the label column, you can also update the paper_trail_event, e.g. file.update!(label:'Foo', paper_trail_event: 'update label')
. Then you can query on the event, e.g. versions.where(event: 'update label')
Upvotes: 1