zer3f
How to pass second actor parameter to the ash_paper trail
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
Marked As Solved
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_id based 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.
Also Liked
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.
Popular in Questions
Other popular topics
Categories:
Sub Categories:
Forums
Popular Tags
- #ecto
- #liveview
- #troubleshooting
- #learning-elixir
- #deployment
- #library
- #erlang
- #testing
- #genserver
- #mix
- #absinthe
- #remote-other
- #otp
- #plug
- #how-to-question
- #macros
- #postgres
- #channels
- #elixirconf
- #exunit
- #discussion
- #code-sync
- #javascript
- #podcasts
- #onsite
- #dialyzer
- #docker
- #authentication
- #umbrella
- #full-time-contract
- #podcasts-by-brainlid
- #ecto-query
- #elixir-ls
- #phoenix_html
- #iex
- #blog-post
- #graphql
- #genstage
- #ai
- #websockets
- #supervisor
- #advent-of-code
- #elixirconf-us
- #distillery
- #processes
- #forms
- #api
- #metaprogramming
- #security
- #performance









