mendomedia

mendomedia

Programming Phoenix 1.4 hurdle: "no action :update" error thrown via helper.ex

I’m working though the rumbl example in the Programming Phoenix 1.4 book. I added the user and credential code to an example new app and it’s working fine. I decided to add the ability to edit a user, which isn’t part of the rumbl code examples.

I removed the original “only: [:index, :show, :new, :create]” constraints for “/users” in the router, created the edit template and added edit and update functions to usercontroller.ex (taken from another app that used phx.gen.html to add user functionality).

When I try to load the edit page, I get this error:

ArgumentError at GET /users/1/edit

no action :update for helper MyappWeb.Router.Helpers.user_path/2.

The following actions/clauses are supported:

user_path(conn_or_endpoint, :create, params \ )
user_path(conn_or_endpoint, :delete, id, params \ )
user_path(conn_or_endpoint, :edit, id, params \ )
user_path(conn_or_endpoint, :index, params \ )
user_path(conn_or_endpoint, :new, params \ )
user_path(conn_or_endpoint, :show, id, params \ )
user_path(conn_or_endpoint, :update, id, params \ )

[lib/phoenix/router/helpers.ex]

The routes list seems to indicate the update function that’s referenced in the edit template action is valid. I have an update function in the controller.
Does this necessarily mean I need to add something to lib/phoenix/router/helpers.ex?

Marked As Solved

cdfuller

cdfuller

Are you calling Routes.user_path in the edit.html.eex view?
Is it possible you called Routes.user_path(@conn, :update, id) without the ID?

Also Liked

mendomedia

mendomedia

Bingo, that was it. Thanks!

I had this:
<%= render “form.html”, Map.put(assigns, :action, Routes.user_path(@conn, :update)) %>

Needed this:
<%= render “form.html”, Map.put(assigns, :action, Routes.user_path(@conn, :update, @user)) %>

Where Next?

Popular in Questions Top

RisingFromAshes
I’ve read in another post that it may be possible with a router helper - but I couldn’t find an appropriate one, and tbh, I’m still just ...
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
joaquinalcerro
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
Qqwy
Original source of discussion: This topic on the Pragmatic Programmers’ Functional Web Development with Elixir, OTP, and Phoenix forum. ...
New
hariharasudhan94
I would like to know what is the best IDE for elixir development?
New
skosch
To my knowledge, put_in, Map.update etc. all have the one limitation of not automatically creating intermediate keys when needed (for exa...
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
beno
I will often find my self writing things similar to: case some_value do nil -&gt; something() "" -&gt; something() _ -&gt; somethi...
New
belgoros
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
Patoshizzle
After calling mix ecto.create I get this error: 17:00:32.162 [error] GenServer #PID&lt;0.412.0&gt; terminating ** (Postgrex.Error) FATAL...
New

Other popular topics Top

Qqwy
Original source of discussion: This topic on the Pragmatic Programmers’ Functional Web Development with Elixir, OTP, and Phoenix forum. ...
New
New
Brian
What is the proper way to load a module from a file in to IEX? In the python world, doing something like this pretty standard: from ....
New
dokuzbir
I want to highlight html closing tags when i click a html tag. That works in .html files but doesnt work for html.eex templates. How can...
New
chrismccord
Phoenix 1.4.0 released Phoenix 1.4 is out! This release ships with exciting new features, most notably with HTTP2 support, improved deve...
688 31013 112
New
9mm
I am constructing a JSON object (map) and I need to conditionally set a field. I’m trying to write proper elixir-way code… and I’m at a l...
New
fireproofsocks
Forgive me if this is obvious, but how does one delete a database record WITHOUT selecting it first? Ecto.Repo — Ecto v3.14.0 has exampl...
New
stefanluptak
Hello everybody, usually, I use a 29" ultra-wide monitor for VSCode which can easily accomodate explorer (files panel) + file with code ...
New
AngeloChecked
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
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

Latest on Elixir Forum

Elixir Forum

We're in Beta

About us Mission Statement