How to write Link with route path

I’m trying to write link tag to next page xxx_path in phoenix template.

<%= link to: xxx_path(@conn, :main, id) do %>
<% end %>

However I have following error.

** (CompileError) lib/xxx_web/templates/layout/header.html.eex:5: undefined function xxx_path/3

I tell you the phx.routes

C:\Works>mix phx.routes
  xxx_path  GET     /                               xxxWeb.XxxController :index
  xxx_path  GET     /:id                            xxxWeb.XxxController :main

What is wrong?
Thanks.

It should be…

<%= link to: Routes.xxx_path(@conn, :main, id) do %>
2 Likes

Previously it had worked. When Routes. gotta to be need?

I don’t recall if it has been introduced in Phoenix 1.3 or 1.4… but now it is needed.

UPDATE: 1.4

1 Like