2016-07-30 4 views
1
내가 ChicagoBoss MVC 웹 프레임 워크를 배우려고 노력하고

에 before_ 호출 후 호출이 튜토리얼은 좋은 시작컨트롤러 조치가 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 속성에 또는 함수를 선언 할 때 잘못된 이름이나 구조를 작성했습니다. 이 오류는 지정된 함수를 컴파일 할 수 없을 때 출력됩니다. 대개 마침표가있는 함수를 끝내는 것을 잊어 버리는 등의 구문 오류 때문입니다.