user483040
user483040

Reputation:

Phoenix LiveView add/update schema is using POST instead of Websockets

I created a toy app using Phoenix/LiveView. I used the generators to create things. It's possible I messed with routes. The app is a simple CRUD, list-o-stuff application. Nothing tricky.

I can see the list of sets (my schema/struct). I can open up the modal dialog to add all the information but when I click the button to save it, I get this error:

"no route found for POST /sets/new (TumblingDiceWeb.Router)"

And the stack trace:

 deps/phoenix/lib/phoenix/router.ex:487 TumblingDiceWeb.Router.call/2
 lib/tumbling_dice_web/endpoint.ex:1 TumblingDiceWeb.Endpoint.plug_builder_call/2
 deps/plug/lib/plug/debugger.ex:136 TumblingDiceWeb.Endpoint."call (overridable 3)"/2
 lib/tumbling_dice_web/endpoint.ex:1 TumblingDiceWeb.Endpoint.call/2
 phoenix lib/phoenix/endpoint/sync_code_reload_plug.ex:22 Phoenix.Endpoint.SyncCodeReloadPlug.do_call/4
 plug_cowboy lib/plug/cowboy/handler.ex:11 Plug.Cowboy.Handler.init/2
 cowboy /Users/jdkaplan/sources/tumbling_dice/deps/cowboy/src/cowboy_handler.erl:37 :cowboy_handler.execute/2
 cowboy /Users/jdkaplan/sources/tumbling_dice/deps/cowboy/src/cowboy_stream_h.erl:306 :cowboy_stream_h.execute/3
 cowboy /Users/jdkaplan/sources/tumbling_dice/deps/cowboy/src/cowboy_stream_h.erl:295 :cowboy_stream_h.request_process/3
 stdlib proc_lib.erl:240 :proc_lib.init_p_do_apply/3

The error message seems to suggest that I'm not actually submitting via LiveView but by an HTTP Post. I've seen things in other solutions like "clean and rerun npm install" or change the import of such and such. None of these things has worked, but I suspect I'm simply missing something key.

My routes are defined as

  live "/sets", SetLive.Index, :index
  live "/sets/new", SetLive.Index, :new
  live "/sets/:id/edit", SetLive.Index, :edit

  live "/sets/:id", SetLive.Show, :show
  live "/sets/:id/show/edit", SetLive.Show, :edit

In the error message it lists these known routes:

  GET  /                           TumblingDiceWeb.PageController :home
  GET  /sets                       TumblingDiceWeb.SetLive.Index :index
  GET  /sets/new                   TumblingDiceWeb.SetLive.Index :new
  GET  /sets/:id/edit              TumblingDiceWeb.SetLive.Index :edit
  GET  /sets/:id                   TumblingDiceWeb.SetLive.Show :show
  GET  /sets/:id/show/edit         TumblingDiceWeb.SetLive.Show :edit
  GET  /dev/dashboard              Phoenix.LiveDashboard.PageLive :home
  GET  /dev/dashboard/:page        Phoenix.LiveDashboard.PageLive :page
  GET  /dev/dashboard/:node/:page  Phoenix.LiveDashboard.PageLive :page
  *    /dev/mailbox                Plug.Swoosh.MailboxPreview []

As I mentioned above, I just used mix phx.gen* to get the app set up and no custom code anywhere. And as I have no clue where to start, I'm not sure what additional source should be in this question.

I am looking for a solution but simply having a solid list of things I should be checking would be really helpful as well.

Upvotes: 0

Views: 119

Answers (0)

Related Questions