凤凰嵌套路线未被助手识别

时间:2017-01-01 19:49:12

标签: elixir phoenix-framework

所以我跟着this wonderful guide,我遇到了这个似乎没有解决的问题。

我的web/router.ex文件如下所示:

defmodule Pxblog.Router do
  use Pxblog.Web, :router

  pipeline :browser do
    plug :accepts, ["html"]
    plug :fetch_session
    plug :fetch_flash
    plug :protect_from_forgery
    plug :put_secure_browser_headers
  end

  pipeline :api do
    plug :accepts, ["json"]
  end

  scope "/", Pxblog do
    pipe_through :browser # Use the default browser stack

    get "/", PageController, :index
    resources "/users", UserController do
      resources "/posts", PostConroller
    end

    resources "/sessions", SessionController, only: [:new, :create, :delete]
  end

  # Other scopes may use custom stacks.
  # scope "/api", Pxblog do
  #   pipe_through :api
  # end
end

但是当我在模板中使用帮助器时,我收到了undefined function user_post_path/4的编译错误。

抛出错误的行位于模板web/templates/post/edit中,如下所示:

<%= render "form.html", changeset: @changeset, action: user_post_path(@conn, :update, @user, @post) %>

但即使我把这条线拿出来,这也是其他模板中的一个问题。

完整的编译错误是:

== Compilation error on file web/views/post_view.ex
 ==
** (CompileError) web/templates/post/edit.html.eex:
4: undefined function user_post_path/4
    (stdlib) lists.erl:1338: :lists.foreach/2
    (stdlib) erl_eval.erl:670: :erl_eval.do_apply/6
    (elixir) lib/kernel/parallel_compiler.ex:117: a
nonymous fn/4 in Kernel.ParallelCompiler.spawn_comp
ilers/1

为什么会发生这种情况,我该如何解决?

1 个答案:

答案 0 :(得分:-1)

我拼写PostController错了。我是个笨蛋。