Defimpl Phoenix.Param to override the arguments to_param (FunctionClauseError) is not consistent with the function proposal in Phoenix.Param.Rumbl.Video.to_param / 1

while trying to follow the examples in Phoenix Programming (Book) Release P1.0 > ,
everything works fine until he is asked to add 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 adding lines, the tests will pass (as expected):
https://travis-ci.org/dwyl/learn-phoenix-framework/builds/207894163#L384 tests-pass

But after adding defimpl tests will fail:
https://travis-ci.org/dwyl/learn-phoenix-framework/builds/207901757#L349

tests-fail

Error message for two failed tests:

 ** (FunctionClauseError) no function clause matching in Phoenix.Param.Rumbl.Video.to_param/1 

Stack Trace: https://travis-ci.org/dwyl/learn-phoenix-framework/builds/207901757#L349 image

Snapshot of the code when these 5 lines were added: https://github.com/dwyl/learn-phoenix-framework/pull/42/commits/db72acbe83b184cd6ce3fe342ee51c3e39eb5de8

Any help with understanding this would be much appreciated!

Note. I tried to play (for a while) ...
I read dozens of similar questions on SO and https://elixirforum.com ...
but no one helped. I seem to be the only one who saw this error!

Posting a StackOverflow question is my "last resort" before giving up programming! :-(
help me obi-wan

On the Phoenix Programming error page: https://pragprog.com/titles/phoenix/errata, there is another person reporting a problem with the same code, but their error is different ...

errata-not-the-same

+5
source share

Source: https://habr.com/ru/post/1265058/


All Articles