MikaelFangel
I’m trying to use an update action taking an argument, but when I run it, it’s like the argument is never submitted. I’ve been debugging it for some time, and it works when I use the AshAdmin UI, but not from my application. I’m not quite sure what I’m missing?
Simplified update action
update :update do
argument :status, :atom do
allow_nil? false
end
primary? true
end
How I create the update form
form =
resource
|> Form.for_update(:update, forms: [auto?: true])
|> to_form()
The field used to set the status
<.input
name="status"
type="select"
field={@form[:status]}
options={[
{gettext("In Progress"), :in_progress},
{gettext("Pending"), :pending},
]}
/>
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!
Could someone please give me a help/sample code, how to delete a file from s3 using waffle/waffle_ecto from Phoenix app.
I creat...
New
I’m seeing that a list inside a Kino.DataTable will be interpreted as a charlist, even if the Kino.configure() is set to charlists: :as_l...
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
Hi, I’ve just set up an application with ash_authentication. There is only magic link strategy for now, so there is no confirmation add o...
New
If a change or preparation module uses Ash.Changeset.get_argument/2 or Ash.Query.get_argument/2 (or any of the other get_argument functio...
New
I’m trying to set up Emacs with elixir-ls via lsp-mode and credo via Flycheck. This should mostly be preconfigured as Flycheck picks up c...
New
Other Trending Topics
I am happy to introduce the very α version of the new programming language compiled to BEAM.
Welcome Cure.
It has literally three kille...
New
Hobbes is a low-level distributed database for the Elixir programming language.
Hobbes provides a simple, safe, and scalable storage lay...
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
Beam Bots (or just BB for short) is a framework for building fault-tolerant robotics applications in Elixir using familiar OTP patterns. ...
New
Xamal is a deployment tool for Elixir apps that deploys native releases to bare metal servers over SSH. It’s a port of GitHub - basecamp/...
New
Hello everyone. After busy few months I am happy to announce v0.1.0 of Emerge & Solve.
They are GUI (Emerge) and State management (S...
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
- #blog-post
- #elixirconf-us
- #elixir-ls
- #ai
- #phoenix_html
- #iex
- #graphql
- #genstage
- #websockets
- #supervisor
- #advent-of-code
- #distillery
- #processes
- #api
- #forms
- #hex
- #security
- #metaprogramming










Showing Posts 1 to 10- Show Best Posts
- Show All (oldest first)
- Show All (newest first)
barnabasJ
An argument by itself is not doing anything. If you want to update the attribute status, you can use accept for that.
You use arguments for values that aren’t attributes e.g. when accepting values you want to set on a related resource or if you want the user to input something you use to calculate attribute values.
Would also work but is unnecessary if you just accept the attribute
MikaelFangel
My problem is that I try to update the state of the state machine with the line below inside the action. When I update the status from the admin view it actually gets updated, but when I do it from my form nothing happens. As far as I can tell, the argument is nil.
barnabasJ
how do you submit the form? can you show your handle_event callback for that
MikaelFangel
Of course. I have a simplified version of the handle_event here, and I can share the full version if needed, it isn’t that pretty currently, though:
barnabasJ
Have you
dbgd orIO.inspected the params to ensure you get the right value?The input does look right to me, but I haven’t done a lot of live_view yet. So just making sure.
MikaelFangel
Yes, I have inspected the params and would get something like this:
And when inspecting the arguments of my form, I would even get:
barnabasJ
Can you make sure no error is returned from the submission? I checked the code in AshStateMachine, and everything you do looks correct. The only thing I can see happening is it returning a NoMatchingTransitionError
MikaelFangel
This is the form I got, when it failed. I have attached the whole thing this time.
barnabasJ
It’s really strange that in your output, the only key inside all of the params/raw_params attributes is
case.Are you sure you are not doing anything else with params before submitting?
MikaelFangel
I just found the mistake. The mistake was when I created a case through a team relation, I did something like this:
Thus, it expects the case to be in the format
%{case: case}, but when I updated the case I did it through the case resource which expects it as just a map with all the keys and values related to the attributes.The error happened because there was a logic error in how I switched between these two formats. I don’t know if there is a smarter way of doing this, so I don’t have to switch between the two types of maps.
Thank you very much for your help and time! It’s really appreciated.