Protocol Phoenix.Param not implemented for []. This protocol is implemented for: Any, Atom, BitString, Integer, Map

Hi

A curious error has arisen in a previously functional piece of code. I have a route that looks like this:

get "/:type/:year/:number", MyController, :show

I’ve been using this path helper successfully for ages:

<%= link( to: my_path( @conn, :show, type, year, number ) ) do %>

But now it throws the above error. I’ve commented out the line so I know it’s the offending clause. I’ve also upgraded to 1.4 so it now looks like

<%= link( to: Routes.my_path( @conn, :show, type, year, number) ) do %>

Same error.
This will be super simple fix I’m sure …

Found this https://github.com/phoenixframework/phoenix/issues/2864

May be related to the order with which my routes are defined in the router …

#Routes.my_path helper
#contents
get “/:type/:year/:number/contents”, MyController, :contents
#section
get “/:type/:year/:number/section/:section_number”, MyController, :show
#group
get “/:type/:year/:number/group/:group_number”, MyController, :show
#part
get “/:type/:year/:number/part/:part_number/chapter/:chapter_number”, MyController, :show
get “/:type/:year/:number/part/:part_number”, MyController, :show
#schedule
get “/:type/:year/:number/schedules”, MyController, :schedules
get “/:type/:year/:number/schedule/:schedule_number/paragraph/:paragraph_number”, MyController, :show
get “/:type/:year/:number/schedule/:schedule_number”, MyController, :show
#whole
get “/:type/:year/:number”, MyController, :show

I’ve rehashed the routes and given them unique defs in the controller. Think it’s fixed!

#Routes.my_path helper
#contents
get "/:type/:year/:number/contents", MyController, :contents
#section
get "/:type/:year/:number/section/:section_number", MyController, :section
#group
get "/:type/:year/:number/group/:group_number", MyController, :group
#part
get "/:type/:year/:number/part/:part_number/chapter/:chapter_number", MyController, :part_chapter
get "/:type/:year/:number/part/:part_number", MyController, :part
#schedule
get "/:type/:year/:number/schedules", MyController, :schedules
get "/:type/:year/:number/schedule/:schedule_number/paragraph/:paragraph_number", MyController, :schedule_paragraph
get "/:type/:year/:number/schedule/:schedule_number", MyController, :schedule
#whole
get "/:type/:year/:number", MyController, :show
3 Likes

For note, that generally happens when a call became ambiguous (parameter count changed), in which case following it up with an empty parameter arg fixes it and makes it unambiguous. :slight_smile:

2 Likes