Something wrong is with using the .simple_form
component in the promo_live.html.heex
template. Instead of seeing the content described on page 138, the terminal is blown up with errors:
info] GET /promo
[debug] Processing with PentoWeb.PromoLive.Elixir.PentoWeb.PromoLive/2
Parameters: %{}
Pipelines: [:browser, :require_authenticated_user]
[debug] QUERY OK source="users_tokens" db=2.4ms idle=355.6ms
SELECT u1."id", u1."email", u1."hashed_password", u1."confirmed_at", u1."inserted_at", u1."updated_at" FROM "users_tokens" AS u0 INNER JOIN "users" AS u1 ON u1."id" = u0."user_id" WHERE ((u0."token" = $1) AND (u0."context" = $2)) AND (u0."inserted_at" > $3::timestamp + (-(60)::numeric * interval '1 day')) [<<3, 128, 2, 62, 131, 5, 195, 59, 158, 179, 89, 125, 88, 138, 13, 56, 193, 231, 10, 167, 213, 135, 96, 69, 170, 245, 195, 148, 246, 34, 110, 27>>, "session", ~U[2023-09-14 08:24:10.817563Z]]
↳ PentoWeb.UserAuth.fetch_current_user/2, at: lib/pento_web/user_auth.ex:93
[info] Sent 500 in 102ms
[error] #PID<0.543.0> running Phoenix.Endpoint.SyncCodeReloadPlug (connection #PID<0.541.0>, stream id 1) terminated
Server: localhost:4000 (http)
Request: GET /promo
** (exit) an exception was raised:
** (KeyError) key :form not found in: %{
__changed__: %{current_user: true},
current_user: #Pento.Accounts.User<
__meta__: #Ecto.Schema.Metadata<:loaded, "users">,
id: "547ac2b9-ec78-42d1-b967-109cc748515e",
email: "test@example.com",
confirmed_at: ~N[2023-08-09 12:18:10],
inserted_at: ~N[2023-08-09 12:14:37],
updated_at: ~N[2023-08-20 06:58:27],
...
>,
flash: %{},
live_action: nil,
socket: #Phoenix.LiveView.Socket<
id: "phx-F4S2WHQvdbb2UgUC",
endpoint: PentoWeb.Endpoint,
view: PentoWeb.PromoLive,
parent_pid: nil,
root_pid: nil,
router: PentoWeb.Router,
assigns: #Phoenix.LiveView.Socket.AssignsNotInSocket<>,
transport_pid: nil,
...
>
}
(pento 0.1.0) lib/pento_web/live/promo_live.html.heex:7: anonymous fn/2 in PentoWeb.PromoLive.render/1
(phoenix_live_view 0.19.5) lib/phoenix_live_view/diff.ex:386: Phoenix.LiveView.Diff.traverse/7
(phoenix_live_view 0.19.5) lib/phoenix_live_view/diff.ex:538: anonymous fn/4 in Phoenix.LiveView.Diff.traverse_dynamic/7
It seems like the key :form
was not found. I even used exactly the same content for promo_live.html.heex
provided in the code snippet link on page 136.