2013-10-13 105 views
0

我遵循REST API和'Building web application with Erlang' book的yaws教程。未找到記錄

我開始$ yaws當出現以下錯誤:

file:path_eval([".","/Users/<uername>"],".erlang"): error on line 3: 3: evaluation failed with reason error:{undefined_record,airport} and stacktrace [{erl_eval,exprs,2,[]}] 

.erlang文件:

application:start(mnesia). 
mnesia:create_table(airport,[{attributes, record_info(fields, airport)}, {index, [country]}]). 

rest.erl文件可以發現here

如何定義記錄?我試圖添加rd(airport, {code, city, country, name}).沒有成功。

回答

1

記錄'機場'在模塊休息區中定義,'休息'中的所有功能都知道記錄'機場'。但是當你啓動你的應用程序時,erlang會執行.erlang文件,這與模塊休息無關。所以,erlang根本不知道什麼是記錄機場以及在哪裏找到它。

我相信最簡單的

解決方法 - 在其他模塊定義(例如「初始化」)的一些功能,該功能必須包含所有你現在在.erlang文件,將其導出,並在.erlang文件只是調用rest:init()。