I have been following the book Programming Phoenix. I started with the 6th chapter Generators and Relationships and I am not able to follow the book due to the following reasons
The book says to run this command
mix phoenix.gen.html Video videos user_id:references:users \
url:string title:string description:text
I was having problems running this command but changing this to
mix phoenix.gen.html Video Videos user_id :references: users url:string title:string description:text
worked(for that step)
But Instead of creating the required files in the web/controllers, web/templates and web/views directory it creating everything in the lib directory (as given in the screenshot 1 below)
Then when I run mix ecto.migrate command after following the book on page 95 I get this videos_path/3 function undefined error in /lib/rumbl_web/controllers/video_controller.ex line 22 as follows on screenshot 2
line 22 is like this
redirect(to: videos_path(conn, :show, videos))
inside video_controller.ex
and the complete file is as follows:
defmodule RumblWeb.VideosController do
use Rumbl.Web, :controller
alias Rumbl.Video
alias Rumbl.Video.Videos
def index(conn, _params) do
user_id = Video.list_user_id()
render(conn, "index.html", user_id: user_id)
end
def new(conn, _params) do
changeset = Video.change_videos(%Videos{})
render(conn, "new.html", changeset: changeset)
end
def create(conn, %{"videos" => videos_params}) do
case Video.create_videos(videos_params) do
{:ok, videos} ->
conn
|> put_flash(:info, "Videos created successfully.")
|> redirect(to: videos_path(conn, :show, videos))
{:error, %Ecto.Changeset{} = changeset} ->
render(conn, "new.html", changeset: changeset)
end
end
def show(conn, %{"id" => id}) do
videos = Video.get_videos!(id)
render(conn, "show.html", videos: videos)
end
def edit(conn, %{"id" => id}) do
videos = Video.get_videos!(id)
changeset = Video.change_videos(videos)
render(conn, "edit.html", videos: videos, changeset: changeset)
end
def update(conn, %{"id" => id, "videos" => videos_params}) do
videos = Video.get_videos!(id)
case Video.update_videos(videos, videos_params) do
{:ok, videos} ->
conn
|> put_flash(:info, "Videos updated successfully.")
|> redirect(to: videos_path(conn, :show, videos))
{:error, %Ecto.Changeset{} = changeset} ->
render(conn, "edit.html", videos: videos, changeset: changeset)
end
end
def delete(conn, %{"id" => id}) do
videos = Video.get_videos!(id)
{:ok, _videos} = Video.delete_videos(videos)
conn
|> put_flash(:info, "Videos deleted successfully.")
|> redirect(to: videos_path(conn, :index))
end
end
I am unable to get it as I am new to phoenix and elixir. Can someone please help me out here as to where I went wrong and what should I do to solve it,please?


mix phoenix.gen.htmlis a legacy, the generator isphx.gen.htmlfor more than a year already. - Aleksei Matiushkinmix phoenix.gen.html, or do I have to manually remove the files created by this command. - abhishek ranjan