Hello together,
I’m pretty new to Elixir/Phoenix, and so far I’ve read a lot around here and could solve most problems by my own.
But here’s a problem I struggle with for hours now:
** (Phoenix.Router.NoRouteError) no route found for PUT /books (LibraryApiWeb.Router) RESOLVED!
I came across this post from [greyhwndz] and I’m struggling with a similar problem:
My Application refuses to allow updates on user-entries in my Ecto-database.
It says no route found for PUT, when I try to update an existing user in my database. (creating new users works just fine, btw.)
[debug] ** (Phoenix.Router.NoRouteError) no route found for PUT /users/8/edit (TempWeb.Router)
(temp 0.1.0) lib/phoenix/router.ex:405: TempWeb.Router.call/2
(temp 0.1.0) lib/temp_web/endpoint.ex:1: TempWeb.Endpoint.plug_builder_call/2
(temp 0.1.0) lib/plug/debugger.ex:136: TempWeb.Endpoint."call (overridable 3)"/2
(temp 0.1.0) lib/temp_web/endpoint.ex:1: TempWeb.Endpoint.call/2
(phoenix 1.6.13) lib/phoenix/endpoint/cowboy2_handler.ex:54: Phoenix.Endpoint.Cowboy2Handler.init/4
(cowboy 2.9.0) /Users/jesperullmann/Projects/temp/deps/cowboy/src/cowboy_handler.erl:37: :cowboy_handler.execute/2
(cowboy 2.9.0) /Users/jesperullmann/Projects/temp/deps/cowboy/src/cowboy_stream_h.erl:306: :cowboy_stream_h.execute/3
(cowboy 2.9.0) /Users/jesperullmann/Projects/temp/deps/cowboy/src/cowboy_stream_h.erl:295: :cowboy_stream_h.request_process/3
(stdlib 4.0.1) proc_lib.erl:240: :proc_lib.init_p_do_apply/3
In the original topic [kokolegorille] mentioned that, in my case, the router doesn’t get the user_id when updating, but inside my edit.html.form, I am providing the @user reference which should contain the necessary user_id:
<h1>Edit User</h1>
<%= render "user_form.html", Map.put(assigns, :action, Routes.user_path(@conn, :update, @user)) %>
Any ideas on that, how I can fix the update function for user entries in my project? What am I missing here?
Here’s a link to my recent project repository:
[Temp Project]
(https://github.com/y3sp3r/temp/blob/master/lib/temp_web/controllers/user_controller.ex)
Thanks in advance