Hello everyone,
I am building an app that contains two scoped areas. One for the users and one for the admins. I created two dashboard live views.
- The first one mounted on “/”
- The second one mounted on “/admin”
There are the codes I wrote:
scope "/", MyAppWeb do
pipe_through :browser
live "/", DashboardLive
end
scope "/admin", MyAppWeb, as: "admin" do
live "/", Admin.DashboardLive, as: "dashboard"
end
Live views:
defmodule MyAppWeb.Admin.DashboardLive do
use MyAppWeb, :live_view
@impl true
def mount(_params, _session, socket) do
{:ok, assign(socket, title: "Admin Dashboard")}
end
end
defmodule MyAppWeb.DashboardLive do
use MyAppWeb, :live_view
@impl true
def mount(_params, _session, socket) do
{:ok, assign(socket, title: "User Dashboard")}
end
end
Templates
<div><%= Routes.live_path(@socket, MyAppWeb.DashboardLive) %></div>
<div><%= Routes.live_path(@socket, MyAppWeb.Admin.DashboardLive) %></div>
Unfortunately when I am going to /
I have an error that explains me the live_path does not exist for my Admin scoped route.
When I am going to “/admin” everything works:
I am not sure if I am doing it well or if I miss something?
I created a sample repo that reproduce this “bug”: https://github.com/Malian/phoenix-live-view-scoped-path-bug
Does someone see my error or should I report a bug to the phoenix live view repository ?
Thank you!