ghenry

ghenry

Programming Phoenix LiveView: assign_demographic issue p179

Hi all,

I’m getting this when going to /survey and all code appears to be the same:

Request: GET /survey
** (exit) an exception was raised:
    ** (FunctionClauseError) no function clause matching in PentoWeb.DemographicLive.Form.assign_demographic/1
        (pento 0.1.0) lib/pento_web/live/demographic_live/form.ex:16: PentoWeb.DemographicLive.Form.assign_demographic(#Phoenix.LiveView.Socket<assigns: %{__changed__: %{flash: true, id: true, user: true}, flash: %{}, id: "demographic-form", myself: %Phoenix.LiveComponent.CID{cid: 1}, user: #Pento.Accounts.User<__meta__: #Ecto.Schema.Metadata<:loaded, "users">, confirmed_at: nil, email: "ghenry@suretec.co.uk", id: 2, inserted_at: ~N[2022-05-27 09:51:04], updated_at: ~N[2022-05-27 09:51:04], username: "", ...>}, endpoint: PentoWeb.Endpoint, id: "phx-FxEBqzi2O1ybsgYI", parent_pid: nil, root_pid: nil, router: PentoWeb.Router, transport_pid: nil, view: PentoWeb.SurveyLive, ...>)
        (pento 0.1.0) lib/pento_web/live/demographic_live/form.ex:11: PentoWeb.DemographicLive.Form.update/2
        (phoenix_live_view 0.17.10) lib/phoenix_live_view/utils.ex:394: Phoenix.LiveView.Utils.maybe_call_update!/3
        (phoenix_live_view 0.17.10) lib/phoenix_live_view/diff.ex:608: anonymous fn/5 in Phoenix.LiveView.Diff.render_pending_components/6
        (elixir 1.13.4) lib/enum.ex:2396: Enum."-reduce/3-lists^foldl/2-0-"/3
        (stdlib 3.17.2) maps.erl:410: :maps.fold_1/3

Any pointers?

Thanks.

1 597 6

Marked As Solved

ghenry

ghenry

Found the issue:

Page 181 in the PDF has the code like above, but line 9 should be the key current_user like is shows later in the PDF on page 191 (current_user={@current_user})

Great learning experience though!

Popular Prag Prog topics Top

Travis
Dockerfile: FROM ruby:2.6 RUN apt-get update -yqq RUN apt-get install -yqq --no-install-recommends nodejs COPY . /usr/src/app/ WORKDI...
7 1193 4
New
belgoros
Following the steps described in Chapter 6 of the book, I’m stuck with running the migration as described on page 84: bundle exec sequel...
4 1149 1
New
jamis
The following is cross-posted from the original Ray Tracer Challenge forum, from a post by garfieldnate. I’m cross-posting it so that the...
4 2348 3
New
mikecargal
Title: Hands-On Rust (Chapter 11: prefab) Just played a couple of amulet-less games. With a bit of debugging, I believe that your can_p...
22 1618 20
New
joepstender
The generated iex result below should list products instead of product for the metadata. (page 67) iex&gt; product = %Product{} %Pento....
0 1798 20
New
alanq
This isn’t directly about the book contents so maybe not the right forum…but in some of the code apps (e.g. turbo/06) it sends a TURBO_ST...
1 1363 7
New
AufHe
I’m a newbie to Rails 7 and have hit an issue with the bin/Dev script mentioned on pages 112-113. Iteration A1 - Seeing the list of prod...
0 2602 9
New
kolossal
Hi, I need some help, I’m new to rust and was learning through your book. but I got stuck at the last stage of distribution. Whenever I t...
3 1944 5
New
Keton
When running the program in chapter 8, “Implementing Combat”, the printout Health before attack was never printed so I assumed something ...
2 1000 2
New
mcpierce
@mfazio23 I’ve applied the changes from Chapter 5 of the book and everything builds correctly and runs. But, when I try to start a game,...
0 1143 10
New

Other popular topics Top

PragmaticStudio
Let’s get real. As in really knowing—clearly and practically—what’s up with Phoenix LiveView. What is it? How does it work? What can I ...
44 2669 11
New
malloryerik
Any thoughts on Svelte? Svelte is a radical new approach to building user interfaces. Whereas traditional frameworks like React and Vue...
54 3309 17
New
wolf4earth
@AstonJ prompted me to open this topic after I mentioned in the lockdown thread how I started to do a lot more for my fitness. https://f...
193 4259 82
New
DevotionGeo
I know that -t flag is used along with -i flag for getting an interactive shell. But I cannot digest what the man page for docker run com...
7 6542 2
New
AstonJ
There’s a whole world of custom keycaps out there that I didn’t know existed! Check out all of our Keycaps threads here: https://forum....
15 7812 20
New
AstonJ
Seems like a lot of people caught it - just wondered whether any of you did? As far as I know I didn’t, but it wouldn’t surprise me if I...
190 3595 80
New
PragmaticBookshelf
Build efficient applications that exploit the unique benefits of a pure functional language, learning from an engineer who uses Haskell t...
15 4338 2
New
First poster: joeb
The File System Access API with Origin Private File System. WebKit supports new API that makes it possible for web apps to create, open,...
43 2750 22
New
PragmaticBookshelf
Author Spotlight: Peter Ullrich @PJUllrich Data is at the core of every business, but it is useless if nobody can access and analyze ...
72 3682 22
New
AstonJ
This is a very quick guide, you just need to: Download LM Studio: https://lmstudio.ai/ Click on search Type DeepSeek, then select the o...
13 2398 10
New

Latest in PragProg

View all threads ❯