MyAppWeb.Router.Helpers.live_path/2 is undefined or private

I’m using version 0.6.0 of Phoenix Live view. I followed the documentation to do the installation: The settings are exactly the same as in the documentation;

Some things are working well, but when trying to create a link with Routes.live_path the following error is displayed. function MyApp.Router.Helpers.live_path/2 is undefined or private.

<%= link('Click", to: Routes.live_path(@socket, MyApp.ModalLive), phx_click: "show-modal") %>

I tried to look for an answer, but I was unsuccessful.

Do you have a live route definition in your router? Something like live "/modal", ModalLive ?

You’re right @chrismccord , thank you very much. :grinning:

Since I spent a good half hour frustrated by this, I’m adding a comment for others who may find their way here.

I was also getting an undefined or private error for live_path even though I did have a live route. I had generated my project with --live so I knew LV was installed properly.

What I discovered is that if you have defined your live route with an action, like:

live "/", FooLive, :index

Then Routes.live_path will NOT be defined (but Routes.foo_path(socket, :index) will work). It took a long time for me to spot this. Removing the , :index from the router resulted in live_path being defined and operating as the docs outlined!


You just saved me HOURS of pain. Thank you!!!

1 Like