mithereal
Passing a action value from accept to a change
i guess an example would work best, but im trying to pass currency to a changeset via the acton , can you tell me what im doing wrong
actions do
defaults [:read, :destroy]
create :create do
primary? true
accept [
:status,
:customer_id,
:delivery_date,
:invoice_number,
:invoice_status,
:invoiced_at,
:payment_method,
:discount_type,
:discount_value,
:delivery_method,
:currency
]
argument :items, {:array, :map}
change manage_relationship(:items, type: :direct_control)
change {CalculateTotals, [currency: arg(:currency) ]}
change {ValidateConstraints, []}
end
First Post!
zachdaniel
Creator of Ash
You can’t do it currently with attributes the way that you can with arg. You have two options:
- in the change access it via
Ash.Changeset.get_attribute - change it to an argument:
actions do
defaults [:read, :destroy]
create :create do
primary? true
accept [
:status,
:customer_id,
:delivery_date,
:invoice_number,
:invoice_status,
:invoiced_at,
:payment_method,
:discount_type,
:discount_value,
:delivery_method
]
argument :currency, :string
argument :items, {:array, :map}
change set_attribute(:currency, arg(:currency))
change manage_relationship(:items, type: :direct_control)
change {CalculateTotals, [currency: arg(:currency) ]}
change {ValidateConstraints, []}
end
0
Popular in Questions
When I run the Plug and I recompile I wind up having to use Ctrl C to quit iex and start again. Witht the help of rlwrap I can use the cu...
New
To my knowledge, put_in, Map.update etc. all have the one limitation of not automatically creating intermediate keys when needed (for exa...
New
Hi everyone!
I need implement if…else if…else condition from my elixir code, and anymore of this control flow structures not work proper...
New
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
Why is it that the mnesia database isn’t the most preferred database for use in Elixir/Phoenix?
New
I am trying to start a new phoenix project with elixir 1.9, but mix phx.new does not work. It says that ** (Mix) The task "phx.new" could...
New
Hello everybody,
usually, I use a 29" ultra-wide monitor for VSCode which can easily accomodate explorer (files panel) + file with code ...
New
Other popular topics
I have an umbrella app.
Some of the apps inside depend on other apps in the umbrella, unsurprisingly.
I’m writing a test for one of the...
New
Hi everyone!
I need implement if…else if…else condition from my elixir code, and anymore of this control flow structures not work proper...
New
Seen any cool LiveView demos, sample apps or examples? Please post them here! :003:
New
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
This post is an instruction guide to help you setup your Neovim for Elixir development from scratch. It includes general information on h...
New
Kind of like when jquery came out, it was super necessary. Existing drag and drop libraries have a bunch of baggage to support old browse...
New
Latest Ash Threads
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
- #elixirconf-us
- #advent-of-code
- #distillery
- #processes
- #forms
- #api
- #metaprogramming
- #hex
- #security










