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?
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"
.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With