dwyl / learn-phoenix

:fire: Phoenix is the web framework without compromise on speed, reliability or maintainability! Don't settle for less. :rocket:
649 stars 45 forks source link

web/controllers/video_controller.ex:23: undefined function video_path/2 #30

Closed nelsonic closed 7 years ago

nelsonic commented 7 years ago

on page 93 of Programming Phoenix we run mix ecto.migrate ... we're seeing:

== Compilation error on file web/controllers/video_controller.ex ==
** (CompileError) web/controllers/video_controller.ex:23: undefined function video_path/2
    (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

image

nelsonic commented 7 years ago

The issue was that I skipped the step of adding the resource to the browser scope in web/router.ex:

resources "/videos", VideoController

Once that was done, the mix ecto.migrate worked fine. 👍

nelsonic commented 7 years ago

Now getting: image

== Compilation error on file web/views/video_view.ex ==
** (CompileError) web/views/video_view.ex:2: module Rumbl.Router.Helpers is not loaded and could not be found
    expanding macro: Rumbl.Web.__using__/1
    web/views/video_view.ex:2: Rumbl.VideoView (module)
    (elixir) expanding macro: Kernel.use/2
    web/views/video_view.ex:2: Rumbl.VideoView (module)
    (elixir) lib/kernel/parallel_compiler.ex:117: anonymous fn/4 in Kernel.ParallelCompiler.spawn_compilers/1

or

== Compilation error on file web/views/session_view.ex ==
** (CompileError) web/views/session_view.ex:2: module Rumbl.Router.Helpers is not loaded and could not be found
    expanding macro: Rumbl.Web.__using__/1
    web/views/session_view.ex:2: Rumbl.SessionView (module)
    (elixir) expanding macro: Kernel.use/2
    web/views/session_view.ex:2: Rumbl.SessionView (module)
    (elixir) lib/kernel/parallel_compiler.ex:117: anonymous fn/4 in Kernel.ParallelCompiler.spawn_compilers/1
nelsonic commented 7 years ago

Major PEBKAC ...!! (or unclear instructions in the book... but I prefer that I didn't read them fully...)

running mix ecto.migrate too soon means that the DB table gets created before all code changes have been made ... that means you cannot run it again so compilation fails!!

Read through ALL the instructions on Pages 92 - 95 before running mix ecto.migrate then it will all work fine. 👍

image

nelsonic commented 7 years ago

Totes works: image

Added video: image