Hi,
I need an example of a relationship between two models and how the migration tables need to be for postgresql.
I want to model roles and users which can all have one and only one role.
role.erl:
-module(role, [Id, Role_short, Role_long]).
-compile(export_all).
migration:
CREATE TABLE roles(
id serial unique
, role_short text not null
, role_long text not null
);
user.erl
-module(user, [Id, Name, Vpe, RoleId]).
-compile(export_all).
migration:
CREATE TABLE users(
id SERIAL UNIQUE PRIMARY KEY
, name text not null
, vpe text
, roleid integer not null
);
Everything compiles, tables are created on db. But when I go to admin-page and continue to model user, then there's an error (listed below). I guess line 4 gives the most detail: "bad arithmetic expression in boss_record_lib:dummy_record/1"?
What do I need to adjust? I tried several different variations - but no success.
Thanks in advance!
david
error from console.log:
2015-02-28 20:37:23.007 [info] <0.308.0> Route: "/model/model/user"Url
[]
2015-02-28 20:37:23.009 [notice] <0.308.0>@boss_controller_adapter_pmod:action:91 Request Method: 'GET', Tokens: ["user"]
2015-02-28 20:37:23.009 [error] <0.295.0> gen_server <0.295.0> terminated with reason: bad arithmetic expression in boss_record_lib:dummy_record/1 line 76
2015-02-28 20:37:23.010 [error] <0.295.0> CRASH REPORT Process <0.295.0> with 1 neighbours exited with reason: bad arithmetic expression in boss_record_lib:dummy_record/1 line 76 in gen_server:terminate/7 line 804
2015-02-28 20:37:23.010 [error] <0.98.0> Supervisor {<0.98.0>,poolboy_sup} had child boss_db_controller started with {boss_db_controller,start_link,undefined} at <0.295.0> exit with reason bad arithmetic expression in boss_record_lib:dummy_record/1 line 76 in context child_terminated
2015-02-28 20:37:23.014 [error] <0.308.0>@boss_web_controller:call_controller_action:319 Error in controller exit:{{badarith,
[{boss_record_lib,dummy_record,1,
[{file,"src/boss_record_lib.erl"},{line,76}]},
{boss_record_lib,database_columns,1,
[{file,"src/boss_record_lib.erl"},{line,93}]},
{boss_db_adapter_pgsql,build_conditions,2,
[{file,"src/db_adapters/boss_db_adapter_pgsql.erl"},
{line,337}]},
{boss_db_adapter_pgsql,count,3,
[{file,"src/db_adapters/boss_db_adapter_pgsql.erl"},{line,76}]},
{boss_db_controller,handle_call,3,
[{file,"src/boss_db_controller.erl"},{line,138}]},
{gen_server,try_handle_call,4,[{file,"gen_server.erl"},{line,607}]},
{gen_server,handle_msg,5,[{file,"gen_server.erl"},{line,639}]},
{proc_lib,init_p_do_apply,3,[{file,"proc_lib.erl"},{line,237}]}]},
{gen_server,call,[<0.295.0>,{count,user,[]},30000]}} Stacktrace: [{gen_server,call,3,[{file,"gen_server.erl"},{line,190}]},{boss_pool,call,3,[{file,"src/boss_pool.erl"},{line,12}]},{cb_admin_model_controller,model,4,[{file,"/home/david/projects/erlang/cb_admin/src/controller/cb_admin_model_controller.erl"},{line,34}]},{boss_web_controller,call_controller_action,3,[{file,"src/boss/boss_web_controller.erl"},{line,316}]},{boss_web_controller,apply_action,4,[{file,"src/boss/boss_web_controller.erl"},{line,308}]},{boss_web_controller,execute_action_inner,9,[{file,"src/boss/boss_web_controller.erl"},{line,287}]},{boss_web_controller_handle_request,process_dynamic_request,5,[{file,"src/boss/boss_web_controller_handle_request.erl"},{line,254}]},{boss_web_controller_handle_request,process_request,5,[{file,"src/boss/boss_web_controller_handle_request.erl"},{line,244}]}]
2015-02-28 20:37:23.017 [error] <0.308.0> Error in controller, see console.log for details
2015-02-28 20:37:23.017 [error] <0.308.0> GET /admin/model/model/user [cb_admin] 500 0ms