zer3f

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 ?
image. 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 :slight_smile:

Appreciate for any help. Thank you

Marked As Solved

zachdaniel

zachdaniel

Creator of Ash

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

zachdaniel

Creator of Ash

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.

Where Next?

Popular in Questions Top

nobody
How to bind a phoenix app to a specific ip address? could not find anything about that, nowhere, unfortunately, but for me this is quite...
New
johnnyicon
Hi all, I’ve just started learning Elixir and Phoenix Framework, so please pardon my n00bness at this stage. I’m trying to use Postgres...
New
baxterw3b
Hi guys, i’m new in the Elixir world, and i have to say, that i love it! i’m having some problem to understand anonymous functions with ...
New
vonH
In asking this question I am more interested about the expressiveness of the language itself and less concerned about the availability of...
New
lessless
I believe there are people here who are dealing with CSV files import on the daily basis, and since Excel is a really popular tool there ...
New
vac
Hi, I’m quite new in Elixir and I’m trying to format a string to a PEM format. I have the certificate value like MIIDBTCCAe2...... and I...
New
tduccuong
Hi, is there any work on GUI with Elixir, that is similar to Electron/Javascript? My idea is to bundle Phoenix and BEAM into a single se...
New
romenigld
I am trying to run a deploy with docker and I successfully runned with this command: docker build -t romenigld/blog-prod . but when I t...
New
fayddelight
I tried installing elixir 1.11.2 erlang 23.3.4 via asdf in my zsh shell. Enabled the versions locally and globally. When I list them ...
New
JorisKok
I have a server on AWS, and was running a load test using artillery. When looking at the Phoenix dashboard I see the Ports going to 100% ...
New

Other popular topics Top

KronicDeth
Elixir plugin for JetBrain’s IntelliJ Platform (including Rubymine) This is a plugin that adds support for Elixir to JetBrains IntelliJ...
289 36432 110
New
minhajuddin
I have seen a lot of code which picks the first element from a list using Enum.at(0) instead of List.first. Is there a reason why people ...
New
AstonJ
Please see the new poll here: Which code editor or IDE do you use? (Poll) (2022 Edition) It’s been a while since we first asked this, I...
208 31307 143
New
josevalim
Hi everyone, One of the features added to Elixir early on to help integration with Erlang code was the idea of overridable function defi...
New
Qqwy
Original source of discussion: This topic on the Pragmatic Programmers’ Functional Web Development with Elixir, OTP, and Phoenix forum. ...
New
gshaw
What is the idiomatic way of matching for not nil in Elixir? E.g., First way: defp halt_if_not_signed_in(conn, signed_in_account) when...
New
chrismccord
This release brings a number of exciting features, including integration with the new Phoenix LiveDashboard and Phoenix LiveView. There h...
New
pmjoe
I have a relationship of love and hate with Elixir. Lots of things are just absolutely right, but there are some things that are kind of ...
New
dblack
I’ve got an issue with an app and I’ve no idea of how to troubleshoot it. I’m hoping someone here might have seen something similar. I p...
New
malloryerik
Hi, this is for people who, like me, have had some friction using .html.heex templates in VSCode. The solution seems to be, in a hyphena...
New

We're in Beta

About us Mission Statement