
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 Prag Prog topics

In Chapter 3, the source for index introduces Config on page 31, followed by more code including tests; Config isn’t introduced until pag...
New

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

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

Hi, I have just acquired Michael Fazio’s “Kotlin and Android Development” to learn about game programming for Android. I have a game in p...
New

When trying to run tox in parallel as explained on page 151, I got the following error:
tox: error: argument -p/–parallel: expected one...
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

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 @herbert ! Trying to get the very first “Hello, Bracket Terminal!" example to run (p. 53). I develop on an Amazon EC2 instance runn...
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

From page 13:
On Python 3.7, you can install the libraries with pip by running these commands inside a Python venv using Visual Studio ...
New
Other popular topics

@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’ve been really enjoying obsidian.md:
It is very snappy (even though it is based on Electron). I love that it is all local by defaul...
New

Bought the Moonlander mechanical keyboard. Cherry Brown MX switches. Arms and wrists have been hurting enough that it’s time I did someth...
New

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
New

A few weeks ago I started using Warp a terminal written in rust. Though in it’s current state of development there are a few caveats (tab...
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

Build efficient applications that exploit the unique benefits of a pure functional language, learning from an engineer who uses Haskell t...
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

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