Rendering AshPaperTrails
Solution:Jump to solution
In my Member ressource, I have:
```paper_trail do
primary_key_type :uuid
only_when_changed? true
change_tracking_mode :changes_only...
10 Replies
@AngyL75 has experience with this.
Over an API? Or just in your app? In LV?
@allenwyma I don't know of any good public examples, but if you find one let me know.
Oh, sorry. I meant in LiveViews.
In that case, you can interact with the versions resource directly, and/or load the
versions
relationship on the record (I can't remember if thats enabled by default or not, but you can see the DSL options there)Hi @aidalgol, I am using paper_trail to record history of a resource. In my liveview I show the history of modification.
For example, I have a "Member" ressource to connect a User to an Organization. and I can see the history of modication of his status (see screenshot, also, this is temporary html, it needs UX improvement)

Solution
In my Member ressource, I have:
Note:
- in :actor the person who modify the resource is stored
- :store_action_name is very usefull to know which action has been called
The status of my member is an Enum:
Now, when I load my member data in my liveview, I do:
and after I am doing the processing of the version like:
Hi @aidalgol does it reply to your question ?
Mostly, yes, thank you! What does your LiveView (or plain HTML) template look like?
Hi @aidalgol
the code related to the screenshot above is