2017-02-19 1 views
0

https://github.com/trenpixster/addictの手順に従ってPhoenixアプリケーションでAddictを使用してユーザー認証を実装しています。ユーザー認証のためにAddictを使用してPhoenixアプリケーションでエラーを修正する方法

ここで私が得ているエラーです:

[error] #PID<0.549.0> running Myapp.Endpoint terminated 
Server: localhost:4000 (http) 
Request: GET /register 
** (exit) an exception was raised: 
    ** (UndefinedFunctionError) function Myapp.Addict.AddictController.init/1 is undefined (module Myapp.Addict.AddictController is not available) 
     Myapp.Addict.AddictController.init(:register) 
     (myapp) web/router.ex:1: anonymous fn/1 in Myapp.Router.match_route/4 
     (myapp) lib/phoenix/router.ex:261: Myapp.Router.dispatch/2 
     (myapp) web/router.ex:1: Myapp.Router.do_call/2 
     (myapp) lib/myapp/endpoint.ex:1: Myapp.Endpoint.phoenix_pipeline/1 
     (myapp) lib/plug/debugger.ex:123: Myapp.Endpoint."call (overridable 3)"/2 
     (myapp) lib/myapp/endpoint.ex:1: Myapp.Endpoint.call/2 
     (plug) lib/plug/adapters/cowboy/handler.ex:15: Plug.Adapters.Cowboy.Handler.upgrade/4 
     (cowboy) /Users/development/Desktop/myapp/deps/cowboy/src/cowboy_protocol.erl:442: :cowboy_protocol.execute/4 

ここに私のweb/router.exファイルがある:なぜこのエラーが起こっていると私はこれをどのように解決することができ

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

    use Addict.RoutesHelper 

    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 "/", Myapp do 
    pipe_through :browser # Use the default browser stack 

    get "/", PageController, :index 
    get "/about", PageController, :about 
    get "/thanks", PageController, :thanks 
    resources "/projects", ProjectController 

    addict :routes 
    end 

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

ありがとうございます。

+0

stacktraceを含む完全なエラーメッセージを投稿できますか? – Dogbert

+0

ルータのソース( 'web/router.ex')も投稿できますか? – Dogbert

+0

web/router.exのソースも同様に投稿されました:) –

答えて

2

それらが間違ったコントローラ(代わりAddict.AddictControllerMyapp.Addict.AddictController)を指すようになりますaddict経路を含む内に定義されているすべての経路のすべてのコントローラにそのモジュールを付加しますscopeにモジュールエイリアスを渡します。エイリアスモジュールを使用しないでaddict :routesを別のスコープに移動して、この問題を解決できます。

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

    get "/", PageController, :index 
    get "/about", PageController, :about 
    get "/thanks", PageController, :thanks 
    resources "/projects", ProjectController 
end 

scope "/" do 
    addict :routes 
end 
関連する問題