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.

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!

Also Liked

SophieDeBenedetto

SophieDeBenedetto

Author of Programming Phoenix LiveView

Excellent detective work! Thanks so much for catching this and sorry if it sent you down a rabbit hole :slight_smile: I’ll fix this for the next release.

Where Next?

Popular Pragmatic Bookshelf topics Top

abtin
page 20: … protoc command… I had to additionally run the following go get commands in order to be able to compile protobuf code using go...
New
herminiotorres
Hi! I know not the intentions behind this narrative when called, on page XI: mount() |&gt; handle_event() |&gt; render() but the correc...
New
jeremyhuiskamp
Title: Web Development with Clojure, Third Edition, vB17.0 (p9) The create table guestbook syntax suggested doesn’t seem to be accepted ...
New
swlaschin
The book has the same “Problem space/Solution space” diagram on page 18 as is on page 17. The correct Problem/Solution space diagrams ar...
New
brian-m-ops
#book-python-testing-with-pytest-second-edition Hi. Thanks for writing the book. I am just learning so this might just of been an issue ...
New
AndyDavis3416
@noelrappin Running the webpack dev server, I receive the following warning: ERROR in tsconfig.json TS18003: No inputs were found in c...
New
oaklandgit
Hi, I completed chapter 6 but am getting the following error when running: thread 'main' panicked at 'Failed to load texture: IoError(O...
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...
New
a.zampa
@mfazio23 I’m following the indications of the book and arriver ad chapter 10, but the app cannot be compiled due to an error in the Bas...
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,...
New

Other popular topics Top

AstonJ
If it’s a mechanical keyboard, which switches do you have? Would you recommend it? Why? What will your next keyboard be? Pics always w...
New
AstonJ
Or looking forward to? :nerd_face:
New
dasdom
No chair. I have a standing desk. This post was split into a dedicated thread from our thread about chairs :slight_smile:
New
AstonJ
Thanks to @foxtrottwist’s and @Tomas’s posts in this thread: Poll: Which code editor do you use? I bought Onivim! :nerd_face: https://on...
New
New
Margaret
Hello everyone! This thread is to tell you about what authors from The Pragmatic Bookshelf are writing on Medium.
1139 25582 756
New
AstonJ
Biggest jackpot ever apparently! :upside_down_face: I don’t (usually) gamble/play the lottery, but working on a program to predict the...
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 Jamis Buck @jamis This month, we have the pleasure of spotlighting author Jamis Buck, who has written Mazes for Prog...
New
Help
I am trying to crate a game for the Nintendo switch, I wanted to use Java as I am comfortable with that programming language. Can you use...
New

Sub Categories: