Saurabh
Saurabh

Reputation: 73649

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

Upvotes: 18

Views: 6691

Answers (2)

Stryder
Stryder

Reputation: 85

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.

Upvotes: 5

Saurabh
Saurabh

Reputation: 73649

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

Upvotes: 26

Related Questions