2016-07-30 16 views
1

でbefore_呼び出し後に呼び出されていない私はChicagoBoss MVC Webフレームワークと、このチュートリアルを習得しようとしていますコントローラのアクションはChicagoBoss

https://github.com/ChicagoBoss/ChicagoBoss/wiki/an-evening-with-chicago-boss

良いスタートだったようでそれはすべての偉大なとそれまではエキサイティングでした作者はrequired_loginが呼び出されるようにbefore_関数を導入しました。私が直面しています問題は、ここに私のコード

-module(outings_outgoer_controller, [Req]). 
-compile(export_all). 
% -export([list/3]). 

before_ (Action) -> 
    io:fwrite("in before_ Action is: ~s~n", [Action]), 
    case Action of 
     "login" -> 
      ok; 
     "register" -> 
      ok; 
     _ -> 
      io:fwrite(" - login is required for this action!~n", []), %gets printed successfully 
      Outgoer = user_lib:require_login(Req), 
      io:fwrite(" - ~p is logged in~n", [Outgoer]), %gets printed successfully 
      Outgoer 
    end. 

list('GET', [], Outgoer) -> 
    io:fwrite("An outgoer is requesting his list~n", []), % never gets printed 
    {ok, [{outgoer, Outgoer}]} 

であり、ここでrequire_login機能

require_login(Req) -> 
    case Req:cookie("user_id") of 
     undefined -> {redirect, "/outgoer/login"}; 
     Id -> 
      case boss_db:find(Id) of 
       undefined -> {redirect, "/outgoer/login"}; 
       Outgoer -> 
        case Outgoer:session_identifier() =:= Req:cookie("session_id") of 
         false -> {redirect, "/outgoer/login"}; 
         true -> {ok, Outgoer} 
        end 
      end 
    end. 

であり、これは、アクセスしている間、私は私のコンソールで取得版画で、list関数が呼び出されて停止したことですoutgoer/list

in before_ Action is: list 
    - login is required for this action! 
    - {ok,{outgoer,"outgoer-1","mohamed","[email protected]", 
      "a982ff46c5664edc593329ab558445fc"}} is logged in 
20:29:31.439 [notice] [ChicagoBoss] The function outings_outgoer_controller:list/2 is not exported, if in doubt add -export([list/2])) to the module 
20:29:31.440 [info] GET /outgoer/list [outings] 200 18ms 
Reloading outings_outgoer_controller ... fail: nofile. 

私はhttps://github.com/ChicagoBoss/ChicagoBossからChicagoBossをダウンロードし、私はErlang 18で働いています

答えて

0

ドットを使って関数を終了するのを忘れたので、 `list '関数がコンパイルに失敗したので、私は通知outings_outgoer_controller:list/2 is not exportedを得ました。とにかく私はhttp://learnyousomeerlang.com/errors-and-exceptionsからそのヒントを得た、それは

./module.erl:2言う:関数some_function/1未定義 関数が存在しません。
-export属性または関数を宣言するときに、間違った名前またはアリティを書きました。このエラーは、指定された関数をコンパイルできないときにも出力されます。通常は、ピリオドのある関数を終了するのを忘れるなどの構文エラーが原因です。

関連する問題