Evening with erlang tutorial

51 views
Skip to first unread message

Phang Mulianto

unread,
Oct 28, 2016, 2:23:56 AM10/28/16
to ChicagoBoss
Hi, 

i try the tutorial, and stuck in the saving data part, which is the register voter.  After save data it suppose redirect, but got error 500.

here my code as in the tutorial :

register('POST', [], WardBoss) ->
    NewVoter = voter:new(id, Req:post_param("first_name"), Req:post_param("last_name"),
        Req:post_param("address"), Req:post_param("notes"), WardBoss:id()),
    case NewVoter:save() of
        {ok, SavedVoter} -> 
            {redirect, "/voter/view/"++SavedVoter:id()};
            %{redirect, [{action, "list"}]};
            %{ok, [{voter, "ab"}]};
        {error, Errors} ->
           {ok, [{errors, Errors}, {voter, NewVoter}]}
    end.

i try with other way of redirect which documented, but all the same. any direction ?

my erlang instaled on debian 8.1:

Erlang/OTP 17 [erts-6.4.1] [source] [64-bit] [smp:4:4] [async-threads:10] [kernel-poll:false]

Eshell V6.4.1  (abort with ^G)



Thanks,

Mulianto

TX

unread,
Oct 28, 2016, 3:36:31 AM10/28/16
to chicagoboss
Hi Mulianto,

The error message should have tell you the reason, if you are not sure, kindly e-mail us the error message and we will then try to figure out.


------------------ 原始邮件 ------------------
发件人: "Phang Mulianto";<brav...@gmail.com>;
发送时间: 2016年10月28日(星期五) 下午2:23
收件人: "ChicagoBoss"<chica...@googlegroups.com>;
主题: [chicagoboss] Evening with erlang tutorial
--
You received this message because you are subscribed to the Google Groups "ChicagoBoss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to chicagoboss...@googlegroups.com.
Visit this group at https://groups.google.com/group/chicagoboss.
To view this discussion on the web visit https://groups.google.com/d/msgid/chicagoboss/96545761-e418-4a06-b162-93be8cd1dfa1%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Phang Mulianto

unread,
Oct 28, 2016, 4:58:33 AM10/28/16
to ChicagoBoss, 23161...@qq.com
Hi TX,

Here are the web error message. 

We got a problem!

This message will appear in production; you may want to define a 500 handler in /home/mulianto/development/erlangweb/evening/priv/evening.routes

Error:

"Error in controller, see console.log for details\n"

Request:

{sbw,cowboy_simple_bridge,
     {cowboy_bridge,#Ref<0.0.0.144911>},
     false,
     [{<<"first_name">>,<<"Anda">>},
      {<<"last_name">>,<<"bisa">>},
      {<<"address">>,<<"Chicago">>},
      {<<"notes">>,<<"Mantap">>}],
     [],[],none,
     [{<<"host">>,<<"127.0.0.1:8001">>},
      {<<"connection">>,<<"keep-alive">>},
      {<<"content-length">>,<<"59">>},
      {<<"pragma">>,<<"no-cache">>},
      {<<"cache-control">>,<<"no-cache">>},
      {<<"origin">>,<<"http://127.0.0.1:8001">>},
      {<<"upgrade-insecure-requests">>,<<"1">>},
      {<<"user-agent">>,
       <<"Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/51.0.2704.106 Safari/537.36">>},
      {<<"content-type">>,<<"application/x-www-form-urlencoded">>},
      {<<"accept">>,
       <<"text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8">>},
      {<<"referer">>,<<"http://127.0.0.1:8001/voter/register">>},
      {<<"accept-encoding">>,<<"gzip, deflate">>},
      {<<"accept-language">>,<<"en-US,en;q=0.8">>},
      {<<"cookie">>,
       <<"csrftoken=pfMY4UPoNYv8avsfl8gYCDVoHm0xyrv5; AuthSession=bXVsaWFudG86NTgwRjY4NEE6VgjtIAUiJyNrBe9v24dQ9qzMDa0; session_id=e68d8840c82404c1a0e9318148a82659; user_id=ward_boss-1">>}],
     [{<<"csrftoken">>,<<"pfMY4UPoNYv8avsfl8gYCDVoHm0xyrv5">>},
      {<<"authsession">>,
       <<"bXVsaWFudG86NTgwRjY4NEE6VgjtIAUiJyNrBe9v24dQ9qzMDa0">>},
      {<<"session_id">>,<<"e68d8840c82404c1a0e9318148a82659">>},
      {<<"user_id">>,<<"ward_boss-1">>}],
     {response,200,[],[],[]}}

Application info:

{boss_app_info,evening,[],"/static","/doc",all,
               [{evening_01_news,[]}],
               <0.256.0>,<0.257.0>,<0.259.0>,<0.260.0>,
               ["greeting","voter","ward_boss"],
               [],
               ["evening_greeting_controller","evening_user_controller",
                "evening_voter_controller"]}

Fri, 28 October 2016 2:19 p.m.


I cannot get the real problem. Also the records data is saved and can list the data when go to the /voter/list  


And the error from console :

14:19:11.371 [error] POST /voter/register [evening] 500 6ms

14:19:13.794 [error] Error in controller exit:{noproc,{gen_server,call,

                         [{global,boss_news},

                          {created,"voter-13",

                                   [{id,"voter-13"},

                                    {first_name,"Anda"},

                                    {last_name,"bisa"},

                                    {address,"Chicago"},

                                    {notes,"Mantap"},

                                    {ward_boss_id,"ward_boss-1"}]}]}} Stacktrace: [{gen_server,call,2,[{file,"gen_server.erl"},{line,182}]},{boss_record_lib,run_after_hooks,3,[{file,"src/boss_record_lib.erl"},{line,45}]},{boss_db,save_record,2,[{file,"src/boss_db.erl"},{line,423}]},{evening_voter_controller,register,4,[{file,"/home/mulianto/development/erlangweb/evening/src/controller/evening_voter_controller.erl"},{line,23}]},{boss_web_controller,call_controller_action,3,[{file,"src/boss/boss_web_controller.erl"},{line,305}]},{boss_web_controller,apply_action,4,[{file,"src/boss/boss_web_controller.erl"},{line,297}]},{boss_web_controller,execute_action_inner,9,[{file,"src/boss/boss_web_controller.erl"},{line,276}]},{boss_web_controller_handle_request,process_dynamic_request,5,[{file,"src/boss/boss_web_controller_handle_request.erl"},{line,255}]}]

14:19:13.797 [error] "Error in controller, see console.log for details\n"



Thanks,

Mulianto

On Friday, October 28, 2016 at 3:36:31 PM UTC+8, TX wrote:
Hi Mulianto,

The error message should have tell you the reason, if you are not sure, kindly e-mail us the error message and we will then try to figure out.


------------------ 原始邮件 ------------------
发件人: "Phang Mulianto";<brav...@gmail.com>;
发送时间: 2016年10月28日(星期五) 下午2:23
收件人: "ChicagoBoss"<chicagoboss@googlegroups.com>;

TX

unread,
Oct 28, 2016, 6:14:22 AM10/28/16
to chicagoboss
{file,"/home/mulianto/development/erlangweb/evening/src/controller/evening_voter_controller.erl"},{line,23}

Check line 23 of your
evening_voter_controller.erl file


------------------ 原始邮件 ------------------
发件人: "Phang Mulianto";<brav...@gmail.com>;
发送时间: 2016年10月28日(星期五) 下午4:58
收件人: "ChicagoBoss"<chica...@googlegroups.com>;
抄送: "TX"<23161...@qq.com>;
主题: Re: 回复:[chicagoboss] Evening with erlang tutorial

Phang Mulianto

unread,
Oct 28, 2016, 7:05:53 AM10/28/16
to ChicagoBoss, 23161...@qq.com
HI TX,

Below is my 23 lines error. 

Strange is when rebar compile , no error message. it pass compilation. 

register('POST', [], WardBoss) ->
    NewVoter = voter:new(id, Req:post_param("first_name"), Req:post_param("last_name"),
        Req:post_param("address"), Req:post_param("notes"), WardBoss:id()),
    case NewVoter:save() of     <<<==== this is line 23 error, but with rebar compile, there is no error, and this is copy paste from the tutorial.
        {ok, SavedVoter} -> 
            {redirect, "/voter/view/"++SavedVoter:id()};
            %{redirect, [{action, "list"}]};
            %{ok, [{voter, "ab"}]};
        {error, Errors} ->
           {ok, [{errors, Errors}, {voter, NewVoter}]}
    end.


On Friday, October 28, 2016 at 6:14:22 PM UTC+8, TX wrote:
{file,"/home/mulianto/development/erlangweb/evening/src/controller/evening_voter_controller.erl"},{line,23}

Check line 23 of your
evening_voter_controller.erl file


------------------ 原始邮件 ------------------
发件人: "Phang Mulianto";<brav...@gmail.com>;
发送时间: 2016年10月28日(星期五) 下午4:58
收件人: "ChicagoBoss"<chicagoboss@googlegroups.com>;

Phang Mulianto

unread,
Oct 29, 2016, 4:44:47 AM10/29/16
to ChicagoBoss, 23161...@qq.com
So nobody can give a clue ?

to bad , its hard for newbie to understand this without any help.

i plan to convert my django app to chicagoboss but bump on this. 

Jesse Gumm

unread,
Oct 29, 2016, 7:53:34 AM10/29/16
to chica...@googlegroups.com

Hi,

This line in the error message:

{noproc,{gen_server,call,

                         [{global,boss_news},

Means that the boss_news server is not started.

I thought boss_news should be started by default, but I don't know. You might need to e ensure it's started during application startup.

-Jesse


To unsubscribe from this group and stop receiving emails from it, send an email to chicagoboss+unsubscribe@googlegroups.com.

Phang Mulianto

unread,
Oct 30, 2016, 4:07:03 AM10/30/16
to ChicagoBoss
Hi,

i not see any info on the tutorial on boss_news part. How to start it i don't know also.

i will look into the boss_news settings howto.

Thanks 

Mulianto

Jesse Gumm

unread,
Oct 30, 2016, 1:11:46 PM10/30/16
to chica...@googlegroups.com
It should be started here:


But it seems the value isn't being validated and probably should be.

If you run boss_news:start() in the Erlang console, what do you get?

-Jesse

To unsubscribe from this group and stop receiving emails from it, send an email to chicagoboss+unsubscribe@googlegroups.com.

For more options, visit https://groups.google.com/d/optout.



--
Jesse Gumm
Owner, Sigma Star Systems
414.940.4866 || sigma-star.com || @jessegumm

Phang Mulianto

unread,
Oct 31, 2016, 8:25:29 AM10/31/16
to ChicagoBoss
Hi Jesse,

Here my check on boss_web_controller_init.erl :

init_master_node(Env, ThisNode) ->
    MasterNode = boss_env:master_node(),
    if
        MasterNode =:= ThisNode ->
            _ = lager:debug("Starting master services on ~p", [MasterNode]),
            boss_util:ensure_started(boss_mq),
            boss_util:ensure_started(boss_news),
            case boss_env:get_env(smtp_server_enable, false) of
                true ->
                    Options = [
                        {domain,    boss_env:get_env(smtp_server_domain, "localhost")},
                        {address,    boss_env:get_env(smtp_server_address, {0, 0, 0, 0})},
                        {port,        boss_env:get_env(smtp_server_port, 25)},
                        {protocol,    boss_env:get_env(smtp_server_protocol, tcp)},
                        {sessionoptions, [{boss_env, Env}]}],
                    gen_smtp_server:start({global, boss_smtp_server}, boss_smtp_server, [Options]);
                _ ->
                    ok
            end;
        true ->
            _ = lager:debug("Pinging master node ~p from ~p", [MasterNode, ThisNode]),
            pong = net_adm:ping(MasterNode)
    end,
    {ok,MasterNode}.

i use ChicagoBoss-0.9.pre-alpha-2  from git.

What i do is in the evening_01_news.erl add this :

-module(evening_01_news).

-export([init/0, stop/1]).

% This script is first executed at server startup and should
% return a list of WatchIDs that should be cancelled in the stop
% function below (stop is executed if the script is ever reloaded).
init() ->
    boss_news:start(),
    {ok, []}.

and its ok now. no more error and can redirect the page after saving data.

Is this because not latest source ?

Thanks,

Mulianto

Phang Mulianto

unread,
Oct 31, 2016, 8:57:48 AM10/31/16
to ChicagoBoss
Hi ,

And i continue through the test and try cb_admin which previously cannot load, but now i understand a little and can make the cb_admin page show up.
But on page model, error occurs and seems same with the news module, the event module not started, so i try boss_mq:start().  it started on the shell without error and success, then i can access the cb_admin model page.

Hope any new comer can benefit from my experience :)  



thanks,

Mulianto
Reply all
Reply to author
Forward
0 new messages