This a newbie question. I am just going through the step by step sample application in Programming Phoenix (by Chris McCord, Bruce Tate, and José Valim). I am on chapter nine. I am trying to compile the application but I am getting this:
== Compilation error on file web/views/video_view.ex ==
** (CompileError) web/templates/video/index.html.eex:23: undefined function watch_path/3
(stdlib) lists.erl:1338: :lists.foreach/2
(stdlib) erl_eval.erl:670: :erl_eval.do_apply/6
(elixir) lib/kernel/parallel_compiler.ex:117: anonymous fn/4 in Kernel.ParallelCompiler.spawn_compilers/1
So, pretty clear error, right? there is no watch_path function with an arity of three. Silly me I can’t find the error though. View video view simply renders an index template:
defmodule Rumbl.VideoView do
use Rumbl.Web, :view
end
Line 23 of index:
<%= link “Watch”, to: watch_path(@conn, :show, video), class: “btn btn-default btn-xs” %>
What would be the next step backwards I need to look for the missing piece here? I apologise if the question is way too simple, I am most likely missing something but I cannot see what it is.
Basically I am asking what is the troubleshooting path I should follow.
Path_helpers are generated dynamically based on your routes and controllers. That was a bit confusing to me when I started out as well. The documentation does a good job of explaining them.
Running mix phoenix.routes is helpful in seeing what helpers you currently have available with your routes.
Maybe try comparing your code with https://github.com/terakilobyte/rumbl or some other github repo which can be found by googling “github:programming phoenix”.
Right, I actually did that already before posting my question and could not find any difference between the book source code and mine. I’ll try this weekend to untangle it . Thank you for the suggestion, I appreciate it.
One reason it might not be working is that there is a missing “import Rumbl.Router.Helpers” (or if using phoenix 1.3: “import Rumbl.Web.Router.Helpers”). without that, it won’t know what watch_path is supposed to resolve to as there is no watch_path function defined.
… but without seeing your video_view.ex in whole it is a bit harder to guess at what a solution might be.