
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

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...
New

Python Testing With Pytest - Chapter 2, warnings for “unregistered custom marks”
While running the smoke tests in Chapter 2, I get these...
New

Dear Sophie.
I tried to do the “Authorization” exercise and have two questions:
When trying to plug in an email-service, I found the ...
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

I’m under the impression that when the reader gets to page 136 (“View Data with the Database Inspector”), the code SHOULD be able to buil...
New

I found an issue in Chapter 7 regarding android:backgroundTint vs app:backgroundTint.
How to replicate:
load chapter-7 from zipfile i...
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

Is there any place where we can discuss the solutions to some of the exercises? I can figure most of them out, but am having trouble with...
New

Hi,
I am getting an error I cannot figure out on my test.
I have what I think is the exact code from the book, other than I changed “us...
New

Hello @herbert ! Trying to get the very first “Hello, Bracket Terminal!" example to run (p. 53). I develop on an Amazon EC2 instance runn...
New
Other popular topics

Which, if any, games do you play? On what platform?
I just bought (and completed) Minecraft Dungeons for my Nintendo Switch. Other than ...
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

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

New

Just done a fresh install of macOS Big Sur and on installing Erlang I am getting:
asdf install erlang 23.1.2
Configure failed.
checking ...
New

Oh just spent so much time on this to discover now that RancherOS is in end of life but Rancher is refusing to mark the Github repo as su...
New

The V Programming Language
Simple language for building maintainable programs
V is already mentioned couple of times in the forum, but I...
New

Continuing the discussion from Thinking about learning Crystal, let’s discuss - I was wondering which languages don’t GC - maybe we can c...
New

Was just curious to see if any were around, found this one:
I got 51/100:
Not sure if it was meant to buy I am sure at times the b...
New

Author Spotlight
Rebecca Skinner
@RebeccaSkinner
Welcome to our latest author spotlight, where we sit down with Rebecca Skinner, auth...
New
Categories:
Sub Categories:
Popular Portals
- /elixir
- /rust
- /ruby
- /wasm
- /erlang
- /phoenix
- /keyboards
- /rails
- /js
- /python
- /security
- /go
- /swift
- /vim
- /clojure
- /emacs
- /haskell
- /java
- /onivim
- /svelte
- /typescript
- /crystal
- /c-plus-plus
- /kotlin
- /tailwind
- /gleam
- /ocaml
- /react
- /elm
- /flutter
- /vscode
- /ash
- /opensuse
- /centos
- /php
- /deepseek
- /html
- /zig
- /scala
- /textmate
- /sublime-text
- /nixos
- /debian
- /lisp
- /react-native
- /agda
- /kubuntu
- /arch-linux
- /django
- /revery
- /ubuntu
- /spring
- /manjaro
- /nodejs
- /diversity
- /lua
- /c
- /julia
- /slackware
- /markdown