
belgoros
Programming Phoenix LiveView B10: wrong arguments number in RatingLive.Show.stars (page 220)
In PentoWeb.RatingLive.Index.product_rating/1
function, there is a call to <RatingLive.Show.stars rating={rating} product={@product} />
. Later on, the function is referenced as having the only argument:
with the yet-to- be-built Show.stars/1 component…
what is in line with the defined later function:
defmodule PentoWeb.RatingLive.Show do
use Phoenix.Component
use Phoenix.HTML
attr :rating, :any, required: true
def stars(assigns) do
~H"""
<div>
<%= @rating.stars
|> filled_stars()
|> Enum.concat(unfilled_stars(@rating.stars))
|> Enum.join(" ")
|> raw() %>
</div>
"""
end
...
VS Code even displays a warning about it.
Later, on page 224, the call is correct though:
<Show.stars rating={rating} />
One more point regarding defining an alias for alias PentoWeb.RatingLive.Show
on page 224:
Make sure to alias the module in survey_live.ex like this
PentoWeb.RatingLive.
First, the name of the module is not wrong (survey_live.ex
) and should rather be RatingLive.Index
. In this case, as alias PentoWeb.RatingLive
being already aliased (defined on page 218), the correct module to be aliased would be alias PentoWeb.RatingLive.Show
, and alias PentoWeb.RatingLive
should be removed.
Marked As Solved

SophieDeBenedetto
Right you are on both counts! This will be fixed in the final release.
Popular Prag Prog topics










Other popular topics










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