asibbald

asibbald

Programming Phoenix LiveView B2.0: P168 "Render the Demographic Form"

A further clarification: When I move to the “Stateful components” section and run a compile with “iex -S mix”, the compile works. When I then try “mix phx.server” i get the same error as shown below. Interestingly, when I then went back to the stateless directory (where I had originally tried the “mix phx.server” and got the error below, I now got the same error when running “iex -S mix”

When attempting this, the server crashes with an error about @assign content not being available in the eex template. I have diffed all the files created following the book text with the ones in your code zip, but see no differences. Interestingly, the code in the “stateless_components” directory of the zip doesn’t compile either. I’ve copied the two sets of errors below.

I’ve moved on and I’m no longer trying to resolve this. Perhaps I have done something in error that I can’t see myself. But perhaps there is an error in the book’s code. Debugging this is beyond me.

Error when I attempt to compile the code in your zip file (downloaded today) under stateless_components:

== Compilation error in file lib/pento_web/live/product_live/show.ex ==
** (EEx.SyntaxError) /Users/alister/Programming/Practice/elixir/liveview/code/stateless_components/pento/lib/pento_web/live/product_live/show.html.leex:43:1: missing token ‘%>’
(eex 1.11.4) lib/eex/compiler.ex:37: EEx.Compiler.compile/2
(phoenix_live_view 0.15.1) expanding macro: Phoenix.LiveView.Renderer.before_compile/1
lib/pento_web/live/product_live/show.ex:9: PentoWeb.ProductLive.Show (module)
(elixir 1.11.4) lib/kernel/parallel_compiler.ex:314: anonymous fn/4 in Kernel.ParallelCompiler.spawn_workers/7

Error when I attempt to run the code I created following the text in B2.0:

[error] #PID<0.18693.0> running PentoWeb.Endpoint (connection #PID<0.18691.0>, stream id 1) terminated
Server: localhost:4000 (http)
Request: GET /survey
** (exit) an exception was raised:
** (ArgumentError) assign @content not available in eex template.

Please make sure all proper assigns have been set. If this
is a child template, ensure assigns are given explicitly by
the parent template as they are not automatically forwarded.

Available assigns: [:changed, :changeset, :demographic, :flash, :id, :socket, :user]

    (phoenix_live_view 0.15.4) lib/phoenix_live_view/engine.ex:877: Phoenix.LiveView.Engine.fetch_assign!/2
    lib/pento_web/live/demographic_live/form_component.html.leex:1: anonymous fn/2 in PentoWeb.DemographicLive.FormComponent.render/1
    (phoenix_live_view 0.15.4) lib/phoenix_live_view/diff.ex:356: Phoenix.LiveView.Diff.traverse/6
    (phoenix_live_view 0.15.4) lib/phoenix_live_view/diff.ex:430: anonymous fn/4 in Phoenix.LiveView.Diff.traverse_dynamic/6
    (elixir 1.11.4) lib/enum.ex:2193: Enum."-reduce/3-lists^foldl/2-0-"/3
    (phoenix_live_view 0.15.4) lib/phoenix_live_view/diff.ex:356: Phoenix.LiveView.Diff.traverse/6
    (phoenix_live_view 0.15.4) lib/phoenix_live_view/diff.ex:430: anonymous fn/4 in Phoenix.LiveView.Diff.traverse_dynamic/6
    (elixir 1.11.4) lib/enum.ex:2193: Enum."-reduce/3-lists^foldl/2-0-"/3
    (phoenix_live_view 0.15.4) lib/phoenix_live_view/diff.ex:356: Phoenix.LiveView.Diff.traverse/6
    (phoenix_live_view 0.15.4) lib/phoenix_live_view/diff.ex:130: Phoenix.LiveView.Diff.render/3
    (phoenix_live_view 0.15.4) lib/phoenix_live_view/static.ex:288: Phoenix.LiveView.Static.to_rendered_content_tag/4
    (phoenix_live_view 0.15.4) lib/phoenix_live_view/static.ex:148: Phoenix.LiveView.Static.render/3
    (phoenix_live_view 0.15.4) lib/phoenix_live_view/controller.ex:35: Phoenix.LiveView.Controller.live_render/3
    (phoenix 1.5.8) lib/phoenix/router.ex:352: Phoenix.Router.__call__/2
    (pento 0.1.0) lib/pento_web/endpoint.ex:1: PentoWeb.Endpoint.plug_builder_call/2
    (pento 0.1.0) lib/plug/debugger.ex:136: PentoWeb.Endpoint."call (overridable 3)"/2
    (pento 0.1.0) lib/pento_web/endpoint.ex:1: PentoWeb.Endpoint.call/2
    (phoenix 1.5.8) lib/phoenix/endpoint/cowboy2_handler.ex:65: Phoenix.Endpoint.Cowboy2Handler.init/4
    (cowboy 2.8.0) /Users/alister/Programming/Practice/elixir/liveview/pento/deps/cowboy/src/cowboy_handler.erl:37: :cowboy_handler.execute/2
    (cowboy 2.8.0) /Users/alister/Programming/Practice/elixir/liveview/pento/deps/cowboy/src/cowboy_stream_h.erl:300: :cowboy_stream_h.execute/3

First Post!

SophieDeBenedetto

SophieDeBenedetto

Author of Programming Phoenix LiveView

Thanks @asibbald! I’ll look into this and let you know what I find.

Popular Pragmatic 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
johnp
Hi Brian, Looks like the api for tinydb has changed a little. Noticed while working on chapter 7 that the .purge() call to the db throws...
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...
New
jdufour
Hello! On page xix of the preface, it says there is a community forum "… for help if your’re stuck on one of the exercises in this book… ...
New
Mmm
Hi, build fails on: bracket-lib = “~0.8.1” when running on Mac Mini M1 Rust version 1.5.0: Compiling winit v0.22.2 error[E0308]: mi...
New
gilesdotcodes
In case this helps anyone, I’ve had issues setting up the rails source code. Here were the solutions: In Gemfile, change gem 'rails' t...
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
rainforest
Hi, I’ve got a question about the implementation of PubSub when using a Phoenix.Socket.Transport behaviour rather than channels. Before ...
New
mert
AWDWR 7, page 152, page 153: Hello everyone, I’m a little bit lost on the hotwire part. I didn’t fully understand it. On page 152 @rub...
New
dachristenson
I’ve got to the end of Ch. 11, and the app runs, with all tabs displaying what they should – at first. After switching around between St...
New

Other popular topics Top

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
You might be thinking we should just ask who’s not using VSCode :joy: however there are some new additions in the space that might give V...
New
AstonJ
I’ve been hearing quite a lot of comments relating to the sound of a keyboard, with one of the most desirable of these called ‘thock’, he...
New
foxtrottwist
Here’s our thread for the Keyboardio Atreus. It is a mechanical keyboard based on and a slight update of the original Atreus (Keyboardio ...
New
PragmaticBookshelf
Learn different ways of writing concurrent code in Elixir and increase your application's performance, without sacrificing scalability or...
New
First poster: bot
The overengineered Solution to my Pigeon Problem. TL;DR: I built a wifi-equipped water gun to shoot the pigeons on my balcony, controlle...
New
PragmaticBookshelf
Author Spotlight Rebecca Skinner @RebeccaSkinner Welcome to our latest author spotlight, where we sit down with Rebecca Skinner, auth...
New
husaindevelop
Inside our android webview app, we are trying to paste the copied content from another app eg (notes) using navigator.clipboard.readtext ...
New
DevotionGeo
I have always used antique keyboards like Cherry MX 1800 or Cherry MX 8100 and almost always have modified the switches in some way, like...
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...
New

Latest in PragProg

View all threads ❯