mrsnow
Action change not running
Hey. Maybe i’m missing something. I have a create action with some global changes but the changes are not running.
actions do
defaults [:update, :destroy]
read :read do
primary? true
end
read :list do
filter expr(owner == ^actor(:id))
end
create :create do
accept [:subject]
change relate_actor(:owner, allow_nil?: true)
end
update :update_todo do
accept [:subject]
require_atomic? false
end
end
preparations do
prepare build(sort: [due_at: :asc, hashes: :asc, title: :asc])
end
changes do
change {Elephouse.TodoList.Changes.Title, attribute: :title}
change {Elephouse.TodoList.Changes.Hashtags, attribute: :hashes}
change {Elephouse.TodoList.Changes.DueDate, attribute: :due_at}
end
If i change accept [:subject] to an argument the changes run just fine.
So i’m missing something or are changes only run with arguments?
EDIT:
Changing it to this it works:
create :create do
argument :subject, :string
allow_nil_input [:subject]
change set_attribute(:subject, arg(:subject))
change relate_actor(:owner, allow_nil?: true)
end
Marked As Solved
mrsnow
Found the solution for this one.
In the custom Changes i used Ash.Changeset.get_argument which doesn’t get anything when the action only uses attributes.
So changing that to Ash.Changeset.get_argument_or_attribute got them more flexible and they worked again.
1
Popular in Questions
Hi!
In PHP: $_SERVER[‘SERVER_ADDR’] - in Elixir?
Searched the docs for ip address and the web, no good results.
Thanks!
New
Hello, how can I check the Phoenix version ?
Thanks !
New
For some reason my phoenix channels are working for me in my local dev environment, but as soon as I deploy via Docker, I get a 403 error...
New
I am using Ecto timestamps with postgres, I can see the timestamps() use the :naive_dateime but for my use case I wanted to store the ti...
New
In templates/appointment/index.html.eex:
<%= for appointment <- @appointments do %>
<tr>
<td><%= appoi...
New
I’m not a pro in using Regex and can’t figure out why the following behaviour happens, especially if we take into account the difference ...
New
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
Other popular topics
Hi there,
I am working with Ecto-Postgresql and I need to call all of the records from a specific table but the table has 40,000 records...
New
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
Seen any cool LiveView demos, sample apps or examples? Please post them here! :003:
New
Hello!
tl;dr Announcing Oban, an Ecto based job processing library with a focus on reliability and historical observability.
After spen...
New
What learn first? Rust or Elixir
Hi Elixir community!
I’m here because i want learn a new language. I’m a junior developer and mainly i ...
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
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
- #api
- #forms
- #metaprogramming
- #security
- #hex









