Closed rlopzc closed 2 years ago
Hi @romariolopezc , sorry for late response, summer times ;)
originator
supposed to be "the person who does the action" so if the web request is fired by a certain individual, you should already have the person available within that request. However a developer should be able to insert a new PaperTrail.Version
by just just providing originator_id
instead of originator
during PaperTrail.insert
or update or delete, you are indeed right this might not be supported currently: https://github.com/izelnakri/paper_trail/blob/main/lib/paper_trail/serializer.ex#L27
I'm willing to merge a PR that includes this functionality if one provides with a test.
It looks like it is possible to pass a map
with only the originator ID instead of the whole struct like originator: %{id: id}
.
You can see it here -> https://github.com/izelnakri/paper_trail/blob/main/lib/paper_trail/serializer.ex#L26
as @jkmrto pointed out, this feature is currently possible, thus I'm closing this issue. Please let me know if you'd like it to be reopened @rlopzc !
First off, nice repo very helpful!
Use case: I have the user_id inside a
Merchant
struct (belongs_to) and most of the times the user isn't loaded but I do have the originator_id (user_id) available. It would be better to not preload an association that is only going to use the.id
when passing theoriginator: struct