Programming Phoenix LiveView: 'update_changeset' not referenced + small leex typo (page 139)

Hi there,

Just wanted to call out that although what needs to happen should be pretty obvious, when we add handle_progress/3 on page 138-139 (shown below), the update_changeset/3 function we use when the upload completes is not mentioned before or after adding this function. It is in the source code for the book but when coding along you just kind of end up with this missing function not mentioned in the text (as far as I can tell).

 defp handle_progress(:image, entry, socket) do
    # :timer.sleep(1000)
    if entry.done? do
      path =
        consume_uploaded_entry(
          socket,
          entry,
          &upload_static_file(&1, socket)
        )

      {:noreply,
       socket
       |> put_flash(:info, "file #{entry.client_name} uploaded")
       |> update_changeset(:image_upload, path)}
    else
      {:noreply, socket}
    end
  end

Smaller thing on this same page, the example for adding our image to the show template had the img tag not formatted correctly. Notice the ‘>’ after alt attribute as well as not having a closing tag after we add the src.

<article class="column">
<img
alt="product image" width="200" height="200">
src="<%=Routes.static_path(
@socket,
@product.image_upload || "/images/default-thumbnail.jpg")%>"
</article>
<!-- product details... -->

Thanks!

Thank you so much for pointing these out! You’ll find both issues fixed in an upcoming Beta release, if not the next one, then the one after that :grinning_face_with_smiling_eyes:

1 Like