iex(5)> h CoolAppUIWeb.Router.Helpers.article_path
def article_path(conn_or_endpoint, action)
def article_path(conn_or_endpoint, action, params)
def article_path(conn_or_endpoint, action, id, params)
iex(6> CoolAppUIWeb.Router.Helpers.article_path(CoolAppUIWeb.Endpoint, :index, what: :do_you, want: :to_do)
"/articles?what=do_you&want=to_do"
iex(8)> Phoenix.HTML.Link.link("article list link", to: Helpers.article_path(CoolAppUIWeb.Endpoint, :index, what: :do_you, want: :to_do)) |> Phoenix.HTML.safe_to_string()
"<a href=\"/checkout/users?what=do_you&want=to_do\">article list link</a>"
As you can see, the helpers are usually in the singular form of the resource you’re trying to link to and they take a conn or an endpoint as their first argument. The action will be one of the ones defined in your controller.
What exactly are these extra params for?
Edit: I assume you’ve written it the way it’s used in rails so you’re not confused about the link function, but just to be sure I’ve added a link example using the helper.
I am receiving this error when putting a key value
protocol Phoenix.Param not implemented for [custom: :param, another_param: :value2]. This protocol is implemented for: Any, Atom, BitString, Integer, Map
= link "All reviews", to: review_path(@conn, :show, custom: :param, another_param: :value2)