zer3f
Hello,
I am using ash_papertrail for audit logs. But I have setup 2 actors like this:
paper_trail do
# default is :uuid
primary_key_type(:uuid_v7)
# default is :snapshot
change_tracking_mode(:changes_only)
# default is false
store_action_name?(true)
# the primary keys are always ignored
ignore_attributes([:inserted_at, :updated_at])
# default is []
ignore_actions([:destroy])
store_action_inputs?(true)
store_resource_identifier?(true)
# Passed through actor
belongs_to_actor(:user, Mgx.Accounts.User, domain: Mgx.Accounts)
# Have existing relastionship
belongs_to_actor(:company_information, Mgx.Company.CompanyInformation, domain: Mgx.Company)
end
So in the LiveView, I am passing actor as current_user like this which works, but user_id,
form =
company_information
|> AshPhoenix.Form.for_update(:update_company_documents,
as: "company-information",
forms: [auto?: true],
actor: socket.assigns.current_user
)
Since actor can be only one, is there is any way I can pass company_information_id ?
. Or any other way, by removing actor looked into mixin, But didn’t understand properly. I tried putting company_information_id in the params but didn’t work either ![]()
Appreciate for any help. Thank you
Trending in Questions
I’m working on a project that simulates the bumbl example in the programming phoenix book. It acts almost like an email client. We have a...
New
Hello,
I know there is an approach for handling lists that allows for optimized traversal, but I can’t recall the specific method (somet...
New
Hi everyone,
I am toying with the idea of building a “match maker” for giving personal help to people that wants to start coding.
I sta...
New
Documentation
While reading the Scoped Routes section, I noticed that the documentation currently refers to a problem without explainin...
New
So my question is quite simple and i have found no conclusive answer on forum, google or AI.
Should we use :erlang.float for Integer to ...
New
I recently noticed that Elixir’s Logger defaults its primary log level to :debug when no :logger, :level application configuration is pre...
New
I’m new to elixir and just tried to install the elixirLS extension for VScode(ium) and it is throwing some errors that I would like help ...
New
Other Trending Topics
Edit: 2026 May 15 - This post is archived.
Mob is alive!!
Main docs: mob v0.7.11 — Documentation
A bit of explanation for the slightly c...
New
Hey, I’m Jesse and I’m the main contributor behind Dexter, a full-featured, lightning-fast Elixir LSP optimized for large codebases. It s...
New
I am happy to introduce the very α version of the new programming language compiled to BEAM.
Welcome Cure.
It has literally three kille...
New
Hi there! We created Gust: A task orchestrator inspired by Airflow.
For those who have never heard about Aiflow, it’s a Python-based wor...
New
Hi everyone!
The first release candidate for the Expert language server project is now available!
We’ve published a press release detai...
New
Beam Bots (or just BB for short) is a framework for building fault-tolerant robotics applications in Elixir using familiar OTP patterns. ...
New
Categories:
Sub Categories:
Forums
Popular Tags
- #ecto
- #liveview
- #troubleshooting
- #learning-elixir
- #library
- #deployment
- #erlang
- #testing
- #genserver
- #mix
- #absinthe
- #remote-other
- #otp
- #plug
- #how-to-question
- #macros
- #postgres
- #elixirconf
- #channels
- #exunit
- #discussion
- #code-sync
- #podcasts
- #javascript
- #onsite
- #dialyzer
- #docker
- #authentication
- #umbrella
- #full-time-contract
- #podcasts-by-brainlid
- #ecto-query
- #ai
- #elixirconf-us
- #blog-post
- #elixir-ls
- #phoenix_html
- #iex
- #graphql
- #genstage
- #websockets
- #supervisor
- #advent-of-code
- #distillery
- #processes
- #api
- #forms
- #elixirconf-eu
- #metaprogramming
- #hex










Showing Posts 1 to 10- Show Best Posts
- Show All (oldest first)
- Show All (newest first)
zachdaniel
There is only ever one actor as you say, and I don’t think there is way to pass inputs or data through to the version itself. Can you describe more specifically what you’d like to accomplish? You could try adding a “last_updated_by_company” relationship to the main resource, at which point each version would have that available in its changes, if that is what you’re looking for.
zer3f
Sure,
I have an update action from the
company_informationresource that managescompany_documents. This is the action:I think since because of
manage_relationship, I can not find audit version record in the relevant table. So i addedpaper_trailsection in thecompany_documentsresource so that i can track the changes.The business logic is, a
company_informationcan have many_to_many withusers, butcompany_documentsbelongs_tocompany_informationonly, notusers, Although I can get the to which company he made throughcompany_inforamtionandcompany_documentsrelationship, I thought it might be better if we just add thecompany_information_idand get direct queries withuser_idandcompany_information_id, without extra join.zachdaniel
Hmm…you can use the version mixin to add an extra attribute
company_information_id, and a change to look it up for the given inputs.zer3f
Sorry Zach, I tried what you said, but somehow not even new record inserting into the database, maybe syntax issue?
This is how I am able to use paper trail:
and tried to put in
company_information_idin the params like thisNow even the new record is not inserting.
zachdaniel
Are you getting some kind of error?
zer3f
No error. The save event is successful, as a well as relevant data (company_documents) in db. But I can’t see new version of audit log in the table
zachdaniel
Can you try
mainofash_paper_trail?zer3f
Yeah I tried to install from the main. It Still not working. This is the logs: Although I got error, where
Ash.Changeset.fetch_argumentgives tuple, Once i fixed and tried it, Now the the record are succesfully implemented but,company_information_idis stillnil.I also tried to put in the
company_information_idin the nested form params, but no result i am gettingcompany_information_idin themixinMixin:
Here are the logs:
Params:
Create Action:
zachdaniel
Yeah, you won’t get the arguments from the main action call in the version mixin. You may have to run a query there to fetch the
company_information_idbased on the other attributes available to you there. Otherwise we would need to add some kind of feature where the version action gets context set on it like the parent changeset.zer3f
Thanks Zach, I already have context that has actor
current_userthat hascompany_information_id