belgoros

belgoros

Programming Phoenix LiveView B10: Promo page is not displayed (page 138)

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.

Most Liked

jshprentz

jshprentz

To correct this problem, remove from pento/lib/pento_web/live/promo_live.html.heex the div containing a simple form (the div spans pages 136 to 137).

<div>
  <.simple_form
    ...
  </.simple_form>
</div>

The browser will display the output shown on page 138.

Later, after modifying pento/lib/pento_web/live/promo_live.ex as shown on page 138, the div containing the simple form can be restored to pento/lib/pento_web/live/promo_live.html.heex as shown on pages 139 to 140. With these two changes, the browser displays the page containing a signup form as shown on page 141.

Where Next?

Popular Pragmatic Bookshelf topics Top

johnp
Running the examples in chapter 5 c under pytest 5.4.1 causes an AttributeError: ‘module’ object has no attribute ‘config’. In particula...
New
brianokken
Many tasks_proj/tests directories exist in chapters 2, 3, 5 that have tests that use the custom markers smoke and get, which are not decl...
New
New
hgkjshegfskef
The test is as follows: Scenario: Intersecting a scaled sphere with a ray Given r ← ray(point(0, 0, -5), vector(0, 0, 1)) And s ← sphere...
New
adamwoolhether
Is there any place where we can discuss the solutions to some of the exercises? I can figure most of them out, but am having trouble with...
New
taguniversalmachine
Hi, I am getting an error I cannot figure out on my test. I have what I think is the exact code from the book, other than I changed “us...
New
EdBorn
Title: Agile Web Development with Rails 7: (page 70) I am running windows 11 pro with rails 7.0.3 and ruby 3.1.2p20 (2022-04-12 revision...
New
Keton
When running the program in chapter 8, “Implementing Combat”, the printout Health before attack was never printed so I assumed something ...
New
ggerico
I got this error when executing the plot files on macOS Ventura 13.0.1 with Python 3.10.8 and matplotlib 3.6.1: programming_ML/code/03_...
New
redconfetti
Docker-Machine became part of the Docker Toolbox, which was deprecated in 2020, long after Docker Desktop supported Docker Engine nativel...
New

Other popular topics Top

PragmaticBookshelf
Learn from the award-winning programming series that inspired the Elixir language, and go on a step-by-step journey through the most impo...
New
AstonJ
Or looking forward to? :nerd_face:
503 15149 280
New
DevotionGeo
The V Programming Language Simple language for building maintainable programs V is already mentioned couple of times in the forum, but I...
New
Margaret
Hello everyone! This thread is to tell you about what authors from The Pragmatic Bookshelf are writing on Medium.
1147 29994 760
New
mafinar
This is going to be a long an frequently posted thread. While talking to a friend of mine who has taken data structure and algorithm cou...
New
PragmaticBookshelf
Rails 7 completely redefines what it means to produce fantastic user experiences and provides a way to achieve all the benefits of single...
New
PragmaticBookshelf
Author Spotlight Rebecca Skinner @RebeccaSkinner Welcome to our latest author spotlight, where we sit down with Rebecca Skinner, auth...
New
New
PragmaticBookshelf
Build modern server-driven web applications using htmx. Whatever programming language you use, you’ll write less (and cleaner) code. ...
New
AstonJ
Curious what kind of results others are getting, I think actually prefer the 7B model to the 32B model, not only is it faster but the qua...
New

Sub Categories: