
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
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
Author of Programming Phoenix LiveView
Excellent detective work! Thanks so much for catching this and sorry if it sent you down a rabbit hole I’ll fix this for the next release.
1
Popular Pragmatic Bookshelf topics

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

Hi! I know not the intentions behind this narrative when called, on page XI:
mount() |> handle_event() |> render()
but the correc...
New

Title: Web Development with Clojure, Third Edition, vB17.0 (p9)
The create table guestbook syntax suggested doesn’t seem to be accepted ...
New

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

#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

@noelrappin
Running the webpack dev server, I receive the following warning:
ERROR in tsconfig.json
TS18003: No inputs were found in c...
New

Hi,
I completed chapter 6 but am getting the following error when running:
thread 'main' panicked at 'Failed to load texture: IoError(O...
New

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

@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

@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

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

New

No chair. I have a standing desk.
This post was split into a dedicated thread from our thread about chairs :slight_smile:
New

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

Think Again 50% Off Sale »
The theme of this sale is new perspectives on familiar topics.
Enter coupon code ThinkAgain2021 at checkout t...
New

Hello everyone! This thread is to tell you about what authors from The Pragmatic Bookshelf are writing on Medium.
New

Biggest jackpot ever apparently! :upside_down_face:
I don’t (usually) gamble/play the lottery, but working on a program to predict the...
New

Rails 7 completely redefines what it means to produce fantastic user experiences and provides a way to achieve all the benefits of single...
New

Author Spotlight
Jamis Buck
@jamis
This month, we have the pleasure of spotlighting author Jamis Buck, who has written Mazes for Prog...
New

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
Categories:
Sub Categories:
Popular Portals
- /elixir
- /rust
- /wasm
- /ruby
- /erlang
- /phoenix
- /keyboards
- /rails
- /js
- /python
- /security
- /go
- /swift
- /vim
- /clojure
- /java
- /emacs
- /haskell
- /onivim
- /svelte
- /typescript
- /crystal
- /c-plus-plus
- /tailwind
- /kotlin
- /gleam
- /react
- /flutter
- /elm
- /ocaml
- /vscode
- /ash
- /opensuse
- /centos
- /php
- /deepseek
- /html
- /zig
- /scala
- /textmate
- /sublime-text
- /debian
- /nixos
- /lisp
- /agda
- /react-native
- /kubuntu
- /arch-linux
- /ubuntu
- /revery
- /django
- /manjaro
- /spring
- /diversity
- /lua
- /nodejs
- /c
- /slackware
- /julia
- /markdown