Programming Phoenix LiveView: B0.14 errata, part 2

  • p81: live "/products/new", ProductLive.Index, :new – as you noted just above, the generator in Phoenix 1.8 puts this in ProductLive.Form, not Index

  • p82: What’s going on with the output of mix test here? It looks like old output for Phoenix 1.7 (with fails) is immediately followed by new output for Phoenix 1.8 (with no fails). Perhaps delete the 1.7 output.

  • p82: However, the tests actually fail for me because an exercise on page 72 requests of the reader: If a logged in user visits the / route, make them redirect to the /guess route. – this causes the login tests to fail. Perhaps you could mention this and tell the reader to revert that change.

  • p86: create unique_index(:products, [:sku]) – Phoenix 1.8.1 also added the following line before this: create index(:products, [:user_id])

  • p87: Notice the use Ecto.Schema expression. – that line isn’t included in the code snippet above (although it is in the generated file).

  • p88: We build a struct using the embedded function. – what is meant by “embedded function” here?

  • p90: Product.changeset(product, attrs) – this doesn’t work since, as shown on the previous page, Phoenix 1.8 now generates changeset/3 and expects a user scope as the final argument.

    • I had to do something like this instead: Product.changeset(product, attrs, Scope.for_user(%User{}))
  • p93: Notice that each of them uses/use/uses

  • p97: This code uses the changeset/2 function – It’s changeset/3 now, since the scope param was added.

  • p97: scope = Accounts.get_scope_for_user(user.id) – I can’t find any mention of a get_scope_for_user function anywhere online. Please tell me this section wasn’t generated by ChatGPT?

    • Instead, I had to do this: scope = Pento.Accounts.Scope.for_user(user)