undefined函数:MyApp.Addict.Controller.init/1

Sau*_*abh 16 authentication elixir phoenix-framework

我在凤凰城使用addict:1.0.3,我已经按照README指南在我的应用程序中使用登录.当我打电话登录时,我收到以下错误:

[error] #PID<0.2576.0> running MyApp.Endpoint terminated
Server: localhost:4000 (http)
Request: POST /login
** (exit) an exception was raised:
** (UndefinedFunctionError) undefined function: MyApp.Addict.Controller.init/1 (module MyApp.Addict.Controller is not available)
MyApp.Addict.Controller.init(:login)
(my_app) web/router.ex:1: anonymous fn/1 in MyApp.Router.match/4
(my_app) lib/phoenix/router.ex:255: MyApp.Router.dispatch/2
(my_app) web/router.ex:1: MyApp.Router.do_call/2
(my_app) lib/my_app/endpoint.ex:1: MyApp.Endpoint.phoenix_pipeline/1
(my_app) lib/plug/debugger.ex:90: MyApp.Endpoint."call (overridable 3)"/2
(my_app) lib/phoenix/endpoint/render_errors.ex:34: MyApp.Endpoint.call/2
(plug) lib/plug/adapters/cowboy/handler.ex:15: Plug.Adapters.Cowboy.Handler.upgrade/4
(cowboy) src/cowboy_protocol.erl:442: :cowboy_protocol.execute/4
Run Code Online (Sandbox Code Playgroud)

Sau*_*abh 23

这是由于我在以下错误router.ex:

  scope "/", MyApp do
    addict :routes
  end
Run Code Online (Sandbox Code Playgroud)

这应该是:

  scope "/" do
    addict :routes
  end
Run Code Online (Sandbox Code Playgroud)

  • 在我的情况下,它是相反的:我忘了添加`MyApp` :)无论如何,问题解决了. (4认同)

Str*_*der 5

在我的情况下,错误是通过运行解决的:

$ mix deps.compile --force 
Run Code Online (Sandbox Code Playgroud)

产生错误的控制器已经存在了一段时间,并且有一个控制器测试未报告任何错误。