From 6003f3725411e875564054603f6915c5c0d24c90 Mon Sep 17 00:00:00 2001 From: belgoros Date: Wed, 12 Jul 2023 15:39:19 +0200 Subject: [PATCH 1/4] Fix the errors when incrementing the counter value - the name of the action in the CounterController should be :count instead of :home - when passing a value via query parameters, it fails to be updated because the type of the @counter is of type String - add the helper method to the CounterHTML component to convert the String to Integer --- exercises/phoenix_follow_along_counter_app.livemd | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/exercises/phoenix_follow_along_counter_app.livemd b/exercises/phoenix_follow_along_counter_app.livemd index eed8f96a0..fd5fc7946 100644 --- a/exercises/phoenix_follow_along_counter_app.livemd +++ b/exercises/phoenix_follow_along_counter_app.livemd @@ -104,7 +104,7 @@ In `lib/counter_web/router.ex` modify the existing scope with the following. We' scope "/", CounterWeb do pipe_through :browser - get "/", CounterController, :home + get "/", CounterController, :count end ``` @@ -139,6 +139,16 @@ defmodule CounterWeb.CounterHTML do use CounterWeb, :html embed_templates "counter_html/*" + + def to_number(number_as_string) when is_binary(number_as_string) do + number_as_string + |> String.trim() + |> String.to_integer() + end + + def to_number(number) do + number + end end ``` @@ -198,7 +208,7 @@ Add the link to the template in `counter_web/controllers/counter_html/count.html

The current count is: <%= @count %>

<.link - navigate={~p"/?count=#{@count + 1}"} + navigate={~p"/?count=#{to_number(@count) + 1}"} class="bg-cyan-500 hover:bg-cyan-400 text-2xl p-4 mt-4 rounded-full inline-block" > Increment From 0cf7267ef35266e032ff368f4d04c968456e7080 Mon Sep 17 00:00:00 2001 From: belgoros Date: Wed, 12 Jul 2023 20:31:46 +0200 Subject: [PATCH 2/4] Fix a typo Pheonix -> Phoenix --- reading/phoenix_components.livemd | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/reading/phoenix_components.livemd b/reading/phoenix_components.livemd index 26b708793..59f122bda 100644 --- a/reading/phoenix_components.livemd +++ b/reading/phoenix_components.livemd @@ -268,7 +268,7 @@ Here's an example of a form without a changeset that sends a GET request to the ### Internal Components -[Pheonix.Component](https://hexdocs.pm/phoenix_live_view/Phoenix.Component.html) also defines several internal components. +[Phoenix.Component](https://hexdocs.pm/phoenix_live_view/Phoenix.Component.html) also defines several internal components. For example, the `simple_form/1` component in `core_components.ex` relies on the [form/1](https://hexdocs.pm/phoenix_live_view/Phoenix.Component.html#form/1) component. From 48cd532efed62941336b94d0be8bbf06fb1538ab Mon Sep 17 00:00:00 2001 From: belgoros Date: Sat, 15 Jul 2023 13:22:16 +0200 Subject: [PATCH 3/4] Remove wrong changes brought from another PR. --- .../phoenix_follow_along_counter_app.livemd | 18 ++++-------------- 1 file changed, 4 insertions(+), 14 deletions(-) diff --git a/exercises/phoenix_follow_along_counter_app.livemd b/exercises/phoenix_follow_along_counter_app.livemd index fd5fc7946..fba4e938c 100644 --- a/exercises/phoenix_follow_along_counter_app.livemd +++ b/exercises/phoenix_follow_along_counter_app.livemd @@ -139,16 +139,6 @@ defmodule CounterWeb.CounterHTML do use CounterWeb, :html embed_templates "counter_html/*" - - def to_number(number_as_string) when is_binary(number_as_string) do - number_as_string - |> String.trim() - |> String.to_integer() - end - - def to_number(number) do - number - end end ``` @@ -209,7 +199,7 @@ Add the link to the template in `counter_web/controllers/counter_html/count.html <.link navigate={~p"/?count=#{to_number(@count) + 1}"} - class="bg-cyan-500 hover:bg-cyan-400 text-2xl p-4 mt-4 rounded-full inline-block" + class="inline-block p-4 mt-4 text-2xl rounded-full bg-cyan-500 hover:bg-cyan-400" > Increment @@ -274,9 +264,9 @@ end For more on Phoenix, consider the following resources. -* [Phoenix HexDocs](https://hexdocs.pm/phoenix/Phoenix.html) -* [Plug HexDocs](https://hexdocs.pm/plug/readme.html) -* [Phoenix a Web Framework for the New Web • José Valim • GOTO 2016](https://www.youtube.com/watch?v=bk3icU8iIto&ab_channel=GOTOConferences) +- [Phoenix HexDocs](https://hexdocs.pm/phoenix/Phoenix.html) +- [Plug HexDocs](https://hexdocs.pm/plug/readme.html) +- [Phoenix a Web Framework for the New Web • José Valim • GOTO 2016](https://www.youtube.com/watch?v=bk3icU8iIto&ab_channel=GOTOConferences) ## Commit Your Progress From 2c52640c0fec02a7103a662af2ddf01db2880a12 Mon Sep 17 00:00:00 2001 From: belgoros Date: Sat, 15 Jul 2023 13:34:03 +0200 Subject: [PATCH 4/4] Fix 2 more Pheonix typos --- exercises/phoenix_drills.livemd | 2 +- reading/phoenix_1.7.livemd | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/exercises/phoenix_drills.livemd b/exercises/phoenix_drills.livemd index 65bc0f4c9..66c3449cf 100644 --- a/exercises/phoenix_drills.livemd +++ b/exercises/phoenix_drills.livemd @@ -54,7 +54,7 @@ $ mix phx.new random_number --no-ecto ## Phoenix Navigation -Create a Pheonix application with three pages: +Create a Phoenix application with three pages: * Home * About diff --git a/reading/phoenix_1.7.livemd b/reading/phoenix_1.7.livemd index a18c618dd..3cbf6fcf7 100644 --- a/reading/phoenix_1.7.livemd +++ b/reading/phoenix_1.7.livemd @@ -50,7 +50,7 @@ Phoenix 1.7 also introduced [Verified Routes](https://hexdocs.pm/phoenix/1.7.0-r ~p"/home" ``` -Many projects in the Elixir ecosystem will still use Pheonix 1.6 or older. While this course focuses on Phoenix 1.7, consider reading the previous [Phoenix 1.6](./deprecated_phoenix_1.6.livemd) section to learn more about the older version. +Many projects in the Elixir ecosystem will still use Phoenix 1.6 or older. While this course focuses on Phoenix 1.7, consider reading the previous [Phoenix 1.6](./deprecated_phoenix_1.6.livemd) section to learn more about the older version.