nelsonic

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! :frowning:

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

Showing Posts 1 to 2

josevalim

josevalim

Creator of Elixir

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

nelsonic OP

Thanks for quick rely @josevalim, you’re correct! (it’s PEBKAC…) :confused:
adding the field :slug, :string Fixed it. :blush:
case closed :white_check_mark:

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… :wink:
Obrigado José! :thumbsup:

— All posts loaded —

Where Next? Top

Trending in Questions Top

RSP87
I’m working on a project that simulates the bumbl example in the programming phoenix book. It acts almost like an email client. We have a...
New
nseaSeb
Hello, I know there is an approach for handling lists that allows for optimized traversal, but I can’t recall the specific method (somet...
New
brecabral
Documentation While reading the Scoped Routes section, I noticed that the documentation currently refers to a problem without explainin...
New
RemyXRenard
I’m seeing that a list inside a Kino.DataTable will be interpreted as a charlist, even if the Kino.configure() is set to charlists: :as_l...
New
velrest
So my question is quite simple and i have found no conclusive answer on forum, google or AI. Should we use :erlang.float for Integer to ...
New
samoloth
Hi, I’ve just set up an application with ash_authentication. There is only magic link strategy for now, so there is no confirmation add o...
New
FlyingNoodle
If a change or preparation module uses Ash.Changeset.get_argument/2 or Ash.Query.get_argument/2 (or any of the other get_argument functio...
New

Other Trending Topics Top

JesseHerrick
Hey, I’m Jesse and I’m the main contributor behind Dexter, a full-featured, lightning-fast Elixir LSP optimized for large codebases. It s...
New
mudasobwa
I am happy to introduce the very α version of the new programming language compiled to BEAM. Welcome Cure. It has literally three kille...
New
marciok
Hi there! We created Gust: A task orchestrator inspired by Airflow. For those who have never heard about Aiflow, it’s a Python-based wor...
New
mhanberg
Hi everyone! The first release candidate for the Expert language server project is now available! We’ve published a press release detai...
New
jimsynz
Beam Bots (or just BB for short) is a framework for building fault-tolerant robotics applications in Elixir using familiar OTP patterns. ...
New
Dmk
Xamal is a deployment tool for Elixir apps that deploys native releases to bare metal servers over SSH. It’s a port of GitHub - basecamp/...
New

We're in Beta

About us Mission Statement

Options

Thread Display Mode




Thread Preview

Skip Thread Previews