I am working on the youtube tutorial from Alchemist Camp - Simple Phoenix LiveView App. It was created using early versions of LiveView. I am trying to complete it using v. 0.16.4. I’ve made it partway through, but I encountered an issue I cannot overcome.
I’m in the process of creating live views. The root route (not a live view) works, but when I try “/users”, I get this:
Request: GET /users
** (exit) an exception was raised:
** (UndefinedFunctionError) function ReactorWeb.UserView.render/2 is undefined or private
Here is the scope from router.ex:
scope "/", ReactorWeb do
pipe_through :browser
live "/users", UserLive.Index
live "/users/new", UserLive.New
live "/users/:id", UserLive.Show
live "/users/:id/edit", UserLive.Edit
resources "/comments", CommentController
resources "/podcast", PodcastController
get "/", PageController, :index
end
This is the UserLive.Index module:
defmodule ReactorWeb.UserLive.Index do
use Phoenix.LiveView
alias Reactor.Accounts
alias ReactorWeb.UserView
**def render(assigns), do: UserView.render("index.html", assigns)** <- this line flagged by VS Code
def mount(_params, _session, socket) do
...
end
T
his is the file *user_view.ex*:
**defmodule ReactorWeb.UserView do** -< also flagged by VS Code
use ReactorWeb, :live_view
def template_not_found(template, _assigns) do
Phoenix.Controller.status_message_from_template(template)
end
end
VS Code shows this message regarding the first line: render/1 was not implemented for ReactorWeb.UserView.
I have a template template/user/index.html.leex.
I went through the installation section of the LIveView docs to make the recommended changes in config.exs, *_web.ex, router.ex, and endpoint.ex.
I suspect I am missing a use, alias, or import somewhere, but I can’t determine where.
Thanks!