Open nelsonic opened 5 years ago
At end of page 34 this is the state of the app:
2 chapters to cover "Hello World" ... ๐ I feel this could be done with fewer words and more clarity. ๐ค
By the end of page 38 this is what you should see:
At the end of P. 48 you should see this: http://localhost:4000/users/
mix phx.routes
Compiling 5 files (.ex)
page_path GET / RumblWeb.PageController :index
user_path GET /users RumblWeb.UserController :index
user_path GET /users/new RumblWeb.UserController :new
user_path GET /users/:id RumblWeb.UserController :show
user_path POST /users RumblWeb.UserController :create
page 64: http://localhost:4000/users/new
p.69 http://localhost:4000/users/new Form error working. ๐
Confirm cannot be blank:
Seeing the following warning:
Compiling 2 files (.ex)
warning: invalid association `credential` in schema Rumbl.Accounts.User: associated schema Credential does not exist
lib/rumbl/accounts/user.ex:1: Rumbl.Accounts.User (module)
warning: function Credential.changeset/2 is undefined (module Credential is not available)
lib/rumbl/accounts/user.ex:23
Derp ... needed to add the line:
alias Rumbl.Accounts.Credential
To the top of the lib/rumbl/accounts/user.ex
file.
No more warnings:
This should work:
$ iex -S mix
iex> alias Rumbl.Accounts.User
iex> alias RumblWeb.Router.Helpers, as: Routes
iex> changeset = User.registration_changeset(%User{}, %{ username: "max", name: "Max", credential: %{ password: "asecret", email: "max@example.com"}})
iex> for u <- Repo.preload(Repo.all(User), :credential) do
Repo.update!(User.registration_changeset(u, %{ credential: %{email: "#{u.username}@example.com",
password: "temppass"}})) end
I โค๏ธ Elixir!
http://localhost:4000/users/new
Password length error message working.
Works when length meets min required (6):
HTML is good as Google Chrome asks to save the password. โ
Minor detour to re-read the docs for Plug https://hexdocs.pm/plug/Plug.Conn.html ๐
on p.88 I'm seeing the following warning:
Access denied: (as expected when user is not logged in) means the auth Plug is working. ๐
Welcome Back! ๐
Login works:
As does logout.
#progresso
๐ง๐ทp.103
mix phx.gen.html Multimedia Video videos user_id:references:users \
url:string title:string description:text
Add the resource to your browser scope in lib/rumbl_web/router.ex:
resources "/videos", VideoController
$ mix ecto.migrate
Now the progress gets faster ...
This is expected on p.117 โ
By p.118 Editing videos works (as expected)
p.121 mix phx.gen.schema Multimedia.Category categories name:string
p.123 mix ecto.gen.migration add_category_id_to_video
edit the resulting migration and add the alter command:
defmodule Rumbl.Repo.Migrations.AddCategoryIdToVideo do
use Ecto.Migration
def change do
alter table(:videos) do
add :category_id, references(:categories)
end
end
end
followed by:
mix ecto.migrate
Select Category working: p.128
Still does not display category on the :show
view. #comingsoon
๐
Ecto supports a wide range of query options see: https://hexdocs.pm/ecto/Ecto.Query.API.html
In short, you can use many of the same comparison, inclusion, search, and aggregate operations for a typical query that youโd use in Elixir. You can see documentation and examples for many of them in the Ecto.Query.API documen- tation.2 Those are the basic features youโre going to use as you build queries. Youโll use them from two APIs: keywords syntax and pipe syntax. Letโs see what each API looks like.
Pipe Syntax queries: p.133
The latest version of the Programming Phoenix 1.4 book is considered "content complete":
So now is a great time to re-read it.
Reading up on how Ecto Sandbox works: https://hexdocs.pm/ecto_sql/Ecto.Adapters.SQL.Sandbox.html it's so much better than any other DB adapter I've used. ๐ฎ
p.167
Each time I sit down to try and read (and follow/type the examples) there are at least 10 GitHub notifications competing for my attention ... I really need a "Reading Tracker" https://github.com/nelsonic/time-mvp-phoenix/issues/3 or more broadly a general purpose "Learning Tracker" collaborative-learning-community.md ...
My plan is to use Phoenix for building the tools. So finishing reading the book is the "egg" ๐ฅthat will hatch into the chicken ... ๐ฃ|> ๐|> ๐
Must stay focussed! ๐จโ๐ป 20 pages today! ๐ฏ
Beta 9 released July 24 ... anyone else
feel the irony of a typo in the release note? ๐
inexing indeed ...
p.204: "_Each channel module has three ways to receive events. Youโll learn more about these callback functions in detail soon. For now, know that handle_in
receives direct channel events, handle_out
intercepts broadcast events, and handle_info
receives OTP messages_".
p.232 Introspecting Applications with Observer
$ iex -S mix
iex> :observer.start()
This is a dream for DevOps and debugging. ๐
When you see the following error:
Module not found: Error: Can't resolve 'phoenix' in 'code/rumbl_umbrella/apps/rumbl_web/assets/js'
Module not found: Error: Can't resolve 'phoenix_html' in 'code/rumbl_umbrella/apps/rumbl_web/assets/js'
Try: https://elixirforum.com/t/phoenix-phoenix-html-npm-error-for-umbrella-project/17575/2 i.e. manually create the symlinks with the following steps:
cd apps/rumbl_web/assets/
rm -f phoenix phoenix
rm -f phoenix phoenix_html
ln -s ../../../../deps/phoenix .
ln -s ../../../../deps/phoenix_html .
npm install
Now the JS will compile. โ
.then
if you see this error (repeatedly):
[error] GenServer #PID<0.461.0> terminating
** (ArgumentError) argument error
(stdlib) :ets.lookup(RumblWeb.Presence, :pool_size)
(phoenix_pubsub) lib/phoenix/tracker.ex:279: Phoenix.Tracker.pool_size/1
(phoenix_pubsub) lib/phoenix/tracker.ex:215: Phoenix.Tracker.list/2
(phoenix) lib/phoenix/presence.ex:355: Phoenix.Presence.list/2
(rumbl_web) lib/rumbl_web/channels/video_channel.ex:23: RumblWeb.VideoChannel.handle_info/2
(phoenix) lib/phoenix/channel/server.ex:305: Phoenix.Channel.Server.handle_info/2
(stdlib) gen_server.erl:637: :gen_server.try_dispatch/4
(stdlib) gen_server.erl:711: :gen_server.handle_msg/6
(stdlib) proc_lib.erl:249: :proc_lib.init_p_do_apply/3
Last message: :after_join
State: %Phoenix.Socket{assigns: %{user_id: 2, video_id: 6}, channel: RumblWeb.VideoChannel, channel_pid: #PID<0.461.0>, endpoint: RumblWeb.Endpoint, handler: RumblWeb.UserSocket, id: "users_socket:2", join_ref: "157", joined: true, private: %{log_handle_in: :debug, log_join: :info}, pubsub_server: RumblWeb.PubSub, ref: nil, serializer: Phoenix.Socket.V2.JSONSerializer, topic: "videos:6", transport: :websocket, transport_pid: #PID<0.457.0>}
Go hunting through the Errata in: https://pragprog.com/titles/phoenix14/errata ๐ I had to make a couple of changes which were a good test of my Umbrella Knowledge.
First in the file apps/rumbl_web/lib/rumbl_web/application.ex
, add RumblWeb.Presence
to the list of supervised child processes, e.g:
children = [
RumblWeb.Endpoint,
RumblWeb.Presence
]
Then in the apps/rumbl_web/lib/rumbl_web/channels/presence.ex
file, change:
use Phoenix.Presence,
otp_app: :rumbl,
pubsub_server: Rumbl.PubSub
to:
use Phoenix.Presence,
otp_app: :rumbl_web,
pubsub_server: RumblWeb.PubSub
Now it works. โ
When you see the following error:
Module not found: Error: Can't resolve 'phoenix' in 'code/rumbl_umbrella/apps/rumbl_web/assets/js'
Module not found: Error: Can't resolve 'phoenix_html' in 'code/rumbl_umbrella/apps/rumbl_web/assets/js'
Try: https://elixirforum.com/t/phoenix-phoenix-html-npm-error-for-umbrella-project/17575/2 i.e. manually create the symlinks with:
.then
if you see this error (repeatedly):
[error] GenServer #PID<0.461.0> terminating
** (ArgumentError) argument error
(stdlib) :ets.lookup(RumblWeb.Presence, :pool_size)
(phoenix_pubsub) lib/phoenix/tracker.ex:279: Phoenix.Tracker.pool_size/1
(phoenix_pubsub) lib/phoenix/tracker.ex:215: Phoenix.Tracker.list/2
(phoenix) lib/phoenix/presence.ex:355: Phoenix.Presence.list/2
(rumbl_web) lib/rumbl_web/channels/video_channel.ex:23: RumblWeb.VideoChannel.handle_info/2
(phoenix) lib/phoenix/channel/server.ex:305: Phoenix.Channel.Server.handle_info/2
(stdlib) gen_server.erl:637: :gen_server.try_dispatch/4
(stdlib) gen_server.erl:711: :gen_server.handle_msg/6
(stdlib) proc_lib.erl:249: :proc_lib.init_p_do_apply/3
Last message: :after_join
State: %Phoenix.Socket{assigns: %{user_id: 2, video_id: 6}, channel: RumblWeb.VideoChannel, channel_pid: #PID<0.461.0>, endpoint: RumblWeb.Endpoint, handler: RumblWeb.UserSocket, id: "users_socket:2", join_ref: "157", joined: true, private: %{log_handle_in: :debug, log_join: :info}, pubsub_server: RumblWeb.PubSub, ref: nil, serializer: Phoenix.Socket.V2.JSONSerializer, topic: "videos:6", transport: :websocket, transport_pid: #PID<0.457.0>}
Go hunting through the Errata in: https://pragprog.com/titles/phoenix14/errata ๐ I had to make a couple of changes which were a good test of my Umbrella Knowledge.
First in the file apps/rumbl_web/lib/rumbl_web/application.ex
, add RumblWeb.Presence
to the list of supervised child processes, e.g:
children = [
RumblWeb.Endpoint,
RumblWeb.Presence
]
Then in the apps/rumbl_web/lib/rumbl_web/channels/presence.ex
file, change:
use Phoenix.Presence,
otp_app: :rumbl,
pubsub_server: Rumbl.PubSub
to:
use Phoenix.Presence,
otp_app: :rumbl_web,
pubsub_server: RumblWeb.PubSub
Now it works. โ
On p.265 getting the following error:
** (ArgumentError) argument error
(stdlib) :ets.insert(InfoSys.Cache_cache, {"one plus one?", "two"})
(info_sys) lib/info_sys/cache.ex:7: InfoSys.Cache.put/2
I tried following https://elixirschool.com/en/lessons/specifics/ets/#inserting-data and get the same error:
After a lot of retracing of steps, I figured out that I failed to follow the instruction on p.261 regarding putting InfoSys.Cache
in the children (supervision tree) in application.ex ๐
** (ArgumentError) could not fetch application environment :wolfram for application :rumbl because configuration :wolfram was not set
After reading the errata for the book https://pragprog.com/titles/phoenix14/errata Found that @samcdavid had spotted and reported the issue:
opened: apps/info_sys/lib/info_sys/wolfram.ex
and changed the last line:
defp id, do: Application.fetch_env!(:rumbl, :wolfram)[:app_id]
To:
defp id, do: Application.fetch_env!(:info_sys, :wolfram)[:app_id]
At the end of Chapter 12 (OTP) we have http://localhost:4000/watch/7
Wolfram alpha is inserting useful info in the annotations thread. ๐
Had to submit another errata: https://pragprog.com/titles/phoenix14/errata #85673
Sadly it is preventing me from finishing Chapter 13. ๐
Really hope they answer/fix it.
Meanwhile I'm going to finish reading chapter 14 "What's Next?" which is unrelated to Rumbl.
Finished reading the Programming Phoenix 1.4 Book. Felt that the last chapter was a bit of a cop-out. It briefly covers LiveView (but only basic demos no full app or useful extension to "Rumbl") and mentions Telemetry but says that the API will change. Touches upon Phoenix Channels 2.0 which is still in development ... I would much rather they pointed to where to go next than finish with "Good Luck". ๐
Overall I would recommend the book. ๐
But I feel they (or someone else
) can still do much better. ๐ญ
With the recent release of the Programming Phoenix 1.4 Book (2018-10-19) see: https://github.com/dwyl/learn-phoenix-framework#book I feel that it would be a good use of my time to re-read it and follow all the examples to ensure that my knowledge is up-to-date for my upcoming Phoenix-based web app projects.
If I sit down and focus, I estimate that it will probably take me 4 days (two uninterrupted weekends...) to read the 269 pages and write the example code.
Better get cracking!