Getting error: module Routes is not available


I am running phoenix 1.7 with elixir 1.14.5 and trying to get path helpers working.

I have enabled them in my app_web.ex file and I see them when I run mix phx.routes

   page_path  GET   /                                      B1Web.PageController :index
hangman_path  GET   /hangman                               B1Web.HangmanController :index
hangman_path  POST  /hangman                               B1Web.HangmanController :new
   websocket  WS    /live/websocket                        Phoenix.LiveView.Socket
    longpoll  GET   /live/longpoll                         Phoenix.LiveView.Socket
    longpoll  POST  /live/longpoll                         Phoenix.LiveView.Socket

Referencing in the code looks like this

  <h1>Welcome to Hangman</h1>
  <%= Phoenix.HTML.Link.button("New game", to: Routes.hangman_path(@conn, :new)) %>

I get this error

module Routes is not available

Not sure what I am doing wrong here…


1 Like

This section of the docs might be relevant: Phoenix.Router — Phoenix v1.7.6

Thanks that helps - silly me :blush:

I was referencing a tutorial that used a different version and it threw me…

The call for my version of phoenix is

1 Like