Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

undefined function: MyApp.Addict.Controller.init/1

I am using addict with Phoenix: 1.0.3, I have followed README guide to use login in my app. I am getting following error when I make a call to login:

[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
like image 820
Saurabh Avatar asked Oct 02 '15 08:10

Saurabh


2 Answers

This was due to my following error in router.ex:

  scope "/", MyApp do
    addict :routes
  end

This should had been:

  scope "/" do
    addict :routes
  end
like image 159
Saurabh Avatar answered Oct 11 '22 10:10

Saurabh


In my case the error was solved by running:

$ mix deps.compile --force 

The controller that produced the errors had existed for a while and there was a controller test that didn't report any errors.

like image 28
Stryder Avatar answered Oct 11 '22 10:10

Stryder