nelsonic
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:
https://github.com/dwyl/learn-phoenix-framework/pull/42/commits/db72acbe83b184cd6ce3fe342ee51c3e39eb5de8
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://forum.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: http://stackoverflow.com/questions/42609234/defimpl-phoenix-param-to-override-to-param-causes-functionclauseerror-no-funct
Trending in Questions
Other Trending Topics
Categories:
Sub Categories:
Forums
Popular Tags
- #ecto
- #liveview
- #troubleshooting
- #learning-elixir
- #library
- #deployment
- #erlang
- #testing
- #genserver
- #mix
- #absinthe
- #remote-other
- #otp
- #plug
- #how-to-question
- #macros
- #postgres
- #elixirconf
- #channels
- #exunit
- #discussion
- #code-sync
- #podcasts
- #javascript
- #onsite
- #dialyzer
- #docker
- #authentication
- #umbrella
- #full-time-contract
- #podcasts-by-brainlid
- #ecto-query
- #elixirconf-us
- #ai
- #blog-post
- #elixir-ls
- #phoenix_html
- #iex
- #graphql
- #genstage
- #websockets
- #supervisor
- #advent-of-code
- #distillery
- #processes
- #api
- #forms
- #metaprogramming
- #hex
- #security












Showing Posts 1 to 2- Show Best Posts
- Show All (oldest first)
- Show All (newest first)
josevalim
If we look at the error, it doesn’t seem that your Video struct has the slug field. Are you sure it is there?
nelsonic
Thanks for quick rely @josevalim, you’re correct! (it’s PEBKAC…)


adding the
field :slug, :stringFixed it.case closed
https://github.com/dwyl/learn-phoenix-framework/pull/42/commits/27c4a115fa9cac4429fa31ce53203931586f52f4
Thankfully this won’t be an issue for much longer once Models are gone in 1.3…

Obrigado José!