XxxxxWeb.Router.Helpers.volunteer_path/3 is undefined or private

Using phoenix 1.6 and I’ve scaffolded out an app called ghcc. I’m getting a routing error as follows:

GhccWeb.Web.Router.Helpers.volunteer_path/3 is undefined or private

I have a context module Volunteers, ecto schema Volunteer and table volunteers. used phx.gen.html to scaffold things out. But anywhere I am navigating that refers to Routes.volunteer_path(…) I get warning messages that Routes.volunteer_path is either undefined or private function. I have NO idea why this is happening. Warning flags are happening for templates, view and controller. Thanks for any help

Hi @wdtnh, can you show your router code?

Thanks for the reply - see router.ex attached below. Things got cleaned up a bit

     resources "/volunteer", VolunteerController to router.ex 

In the view file volunteer_view.ex file I have this and I’m getting a warning shown below

defmodule GhccWeb.VolunteerView do
  use GhccWeb, :view
end
Call to missing or unexported function Elixir.GhccWeb.Router.Helpers':volunteer_path/3

here’s the router.ex file

defmodule GhccWeb.Router do
  use GhccWeb, :router

  pipeline :browser do
    plug :accepts, ["html"]
    plug :fetch_session
    plug :fetch_live_flash
    plug :put_root_layout, {GhccWeb.LayoutView, :root}
    plug :protect_from_forgery
    plug :put_secure_browser_headers
  end

  pipeline :api do
    plug :accepts, ["json"]
  end

  scope "/", GhccWeb do
    pipe_through :browser
    resources "/volunteer", VolunteerController
    get "/", PageController, :index
  end

  # Other scopes may use custom stacks.
  # scope "/api", GhccWeb do
  #   pipe_through :api
  # end

  # Enables LiveDashboard only for development
  #
  # If you want to use the LiveDashboard in production, you should put
  # it behind authentication and allow only admins to access it.
  # If your application does not have an admins-only section yet,
  # you can use Plug.BasicAuth to set up some basic authentication
  # as long as you are also using SSL (which you should anyway).
  if Mix.env() in [:dev, :test] do
    import Phoenix.LiveDashboard.Router

    scope "/" do
      pipe_through :browser

      live_dashboard "/dashboard", metrics: GhccWeb.Telemetry
    end
  end

  # Enables the Swoosh mailbox preview in development.
  #
  # Note that preview only shows emails that were sent by the same
  # node running the Phoenix server.
  if Mix.env() == :dev do
    scope "/dev" do
      pipe_through :browser

      forward "/mailbox", Plug.Swoosh.MailboxPreview
    end
  end
end

is your app raising exceptions and/or compiler warnings in the terminal, or are you getting warnings in your editor/IDE?

I use VSCode with ElixirLS, and in my experience you may get warnings in the editor sometimes when declaring new routes. quitting VSCode, rm -rf .elixir_ls/ , and reopening the editor usually fixes it

1 Like

Thanks - I’ll give that a try. I’m getting warnings in the editor/IDE.