Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

protocol Phoenix.Param not implemented for [token: "12345"]

I have this in router.ex:

    get "/my_url/my_url2/:token", MySuperController, :my_action

When I call this:

<%= link("something", to: my_super_url(@conn, :my_action, token: "12345")) %>

I get an error:

protocol Phoenix.Param not implemented for [token: "12345"]

How can I fix it?

like image 485
Kuqa Avatar asked Feb 05 '23 21:02

Kuqa


1 Answers

You need to pass the variables present in the URL pattern as direct arguments, not in a keyword list:

<%= link("something", to: my_super_url(@conn, :my_action, "12345")) %>

The keyword list at the end is meant for adding query args to the end of the URL, e.g. my_super_url(@conn, :my_action, "12345", foo: "bar") will return "/my_url/my_url2/12345?foo=bar".

like image 81
Dogbert Avatar answered Mar 27 '23 15:03

Dogbert