herminiotorres
Programming Phoenix LiveView - Version B5.0
On Chapter 3 - Page 78, the beginning of the page has this code here:
@doc """
Maybe it is missing to put the Pento context before Catalog.Product.Query?
"""
defmodule Catalog.Product.Query do
...
def base_product_query, do: Product
def cheaper_than(query, price), do: from in query, where...
def cheap_product_skus(price)
base_product_query()
|> chaper_than(price)
|> skus
end
...
end
And for the code almost to the bottom, has some typos. Like:
defmodule Pento.Catalog do
alias Catalog.Product.Query
alias Pento.Repo
def run_query(query) do
{:ok, list} = Repo.all(query)
list
end
def send_sale_skus(query) do
query
|> Product.cheap_product_skus(25.00) # Typo: Query.cheap_product_skus(25.00)
|> run_query
|> Service.send_bargains # Question: the name of the module it is only Service?
end
end
Also, for the next page 79, has more typos too, like:
defmodule Pento.Catalog do
alias Catalog.Product.Query
alias Pento.Repo
@doc """
For the Repo.all API, has only three options:
1. Empty List without any items.
2. List with one or more items.
3. Query doesn't work and raise an error.
"""
def run_query(query) do
Repo.all(query)
end
def send_sale_skus(query) do
query
|> Product.cheap_product_skus(25.00) # Typo: Query.cheap_product_skus(25.00)
|> run_query
end
def send_sale_skus(query)
with {:ok, products} <- send_sale_skus(query), # this line of code here, never pattern matching
{:ok, response} <- Service.send_bargains(products) do # when this line of code it fails? Returns as a tuple with {:error, reason} ?
response
else
# if some error or cas doesn't pattern match in with conditions it will failure here a raise an error with unclause matching.
{:error, reason} ->
IO.puts "Error sending sale skus: #{reason}"
end
end
end
After words this is my feedback even these code as an example, and not intended to use. Besides, I use common comments as #, and some others I use @doc to get my point of view.
Marked As Solved
SophieDeBenedetto
Author of Programming Phoenix LiveView
Thank you for catching these! We’ll fix them for the next release 
Also Liked
SophieDeBenedetto
Author of Programming Phoenix LiveView
Thank you so much for sharing this feedback @herminiotorres! I’ve made some changes to fix the typo and to provide a better example of when to use with statements in your Phoenix context. You’ll find those changes in the next release

1
Popular Pragmatic Bookshelf topics
This test is broken right out of the box…
— FAIL: TestAgent (7.82s)
agent_test.go:77:
Error Trace: agent_test.go:77
agent_test.go:...
New
Hi everyone!
There is an error on the page 71 in the book “Programming machine learning from coding to depp learning” P. Perrotta. You c...
New
Title: Hands-On Rust (Chap 8 (Adding a Heads Up Display)
It looks like
.with_simple_console_no_bg(SCREEN_WIDTH*2, SCREEN_HEIGHT*2...
New
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...
New
Title: Intuitive Python: docker run… denied error (page 2)
Attempted to run the docker command in both CLI and Powershell
PS C:\Users\r...
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
Title: Build a Weather Station with Elixir and Nerves: Problem connecting to Postgres with Grafana on (page 64)
If you follow the defau...
New
It seems the second code snippet is missing the code to set the current_user:
current_user: Accounts.get_user_by_session_token(session["...
New
Modern front-end development for Rails, second edition - Struggling to get the first chapter to work
After running /bin/setup, the first error was: The foreman' command exists in these Ruby versions: That was easy to fix: gem install fore...
New
Hello faithful readers! If you have tried to follow along in the book, you are asked to start up the dev environment via dx/build and ar...
New
Other popular topics
Reading something? Working on something? Planning something? Changing jobs even!?
If you’re up for sharing, please let us know what you’...
New
A thread that every forum needs!
Simply post a link to a track on YouTube (or SoundCloud or Vimeo amongst others!) on a separate line an...
New
@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...
New
I’m thinking of buying a monitor that I can rotate to use as a vertical monitor?
Also, I want to know if someone is using it for program...
New
I have seen the keycaps I want - they are due for a group-buy this week but won’t be delivered until October next year!!! :rofl:
The Ser...
New
Crystal recently reached version 1. I had been following it for awhile but never got to really learn it. Most languages I picked up out o...
New
API 4
Path:
/user/following/
Method:
GET
Description:
Returns the list of all names of people whom the user follows
Response
[
{ ...
New
Hi folks,
I don’t know if I saw this here but, here’s a new programming language, called Roc
Reminds me a bit of Elm and thus Haskell. ...
New
Programming Ruby is the most complete book on Ruby, covering both the language itself and the standard library as well as commonly used t...
New
Hair Salon Games for Girls Fun
Girls Hair Saloon game is mainly developed for kids. This game allows users to select virtual avatars to ...
New
Categories:
Sub Categories:
Popular Portals
- /elixir
- /rust
- /ruby
- /wasm
- /erlang
- /phoenix
- /keyboards
- /rails
- /python
- /js
- /security
- /go
- /swift
- /vim
- /clojure
- /haskell
- /emacs
- /java
- /svelte
- /onivim
- /typescript
- /kotlin
- /c-plus-plus
- /crystal
- /tailwind
- /react
- /gleam
- /ocaml
- /flutter
- /elm
- /vscode
- /ash
- /opensuse
- /html
- /centos
- /php
- /deepseek
- /zig
- /scala
- /sublime-text
- /textmate
- /lisp
- /react-native
- /nixos
- /debian
- /agda
- /kubuntu
- /arch-linux
- /django
- /revery
- /ubuntu
- /manjaro
- /deno
- /spring
- /nodejs
- /diversity
- /lua
- /julia
- /c
- /slackware






