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
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
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)) %>
Popular in Questions
Other popular topics
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
- #advent-of-code
- #elixirconf-us
- #distillery
- #processes
- #forms
- #api
- #metaprogramming
- #security
- #performance









