while
trying to follow the examples in Programming Phoenix (book) release P1.0,
everything is working fine until Page 167 when instructed to add the lines:
defimpl Phoenix.Param, for: Rumbl.Video do
def to_param(%{slug: slug, id: id}) do
"#{id}-#{slug}"
end
end
to: rumbl/web/models/video.ex
Before I add the lines, the tests pass (as expected):
But once the defimpl
is added the tests fail:
The error message for two of the failing tests is:
** (FunctionClauseError) no function clause matching in Phoenix.Param.Rumbl.Video.to_param/1
Stack trace: Travis CI
Code Snapshot when these 5 lines were added:
Any help with understanding this would be much appreciated!
Note: Iâve tried googling (for a while) âŠ
Iâve read through dozens of similar-looking questions on SO & https://elixirforum.com âŠ
but none were helpful. it appears Iâm the only one seeing this error!
Posting a StackOverflow question is my âlast resortâ before giving up programming!
On the âProgramming Phoenixâ bookâs errata page: https://pragprog.com/titles/phoenix/errata there is another person reporting an issue with the same code but their error is different âŠ
Also posted on StackOverflow just in case: web development server - defimpl Phoenix.Param to override to_param causes (FunctionClauseError) no function clause matching in Phoenix.Param.Rumbl.Video.to_param/1 - Stack Overflow