I think, it is a bad idea to study hi-level programming without any
basic erlang skills. It will be better to read basic erlang tutorial
before.
> so it now looks like this:
> -module(appname_my_controller, [Req, SessionID]).
> boss_flash:add(SessionID, notice, "Welcome!", "Your Session has now
> begun!").
- You've forgot to create a function ("action") and
export it. "boss_flash"-line is a code. And code must live inside
function.
- Controller action should return valid result.
http://www.chicagoboss.org/api-controller.html#return_values
-module(appname_my_controller, [Req, SessionID]
-compile(export_all).
my_action() ->
boss_flash:add(SessionID, notice, "Welcome!", "Your S...."),
ok. %% <- valid returned value
ok means "render template src/view/my/my_action.html with no
additional variables".
And now you can make a http-request to
http://.../my/my_action from your web-browser.
В Sun, 4 Nov 2012 05:36:28 -0800 (PST)
"@chrisco" <
chris....@gmail.com> пишет:
> Hi,
>
> I am a beginner programmer (beginner at programming in general and
> Erlang and ChicagoBoss in particular) and am trying to understand
> Sessions and their related Flash Messages in Chicago Boss. I have
> reviewed the tutorial and the API documentation and can't figure it
> out. This is what I've done:
>
> Created headliners_app_controller.erl
> and put this as the one line in it:
>
> -module(headliners_app, [Req, SessionID]).
>
> When I run the app and use a Chrome extension ("Edit This Cookie") I
> see that a session has been created. So far so good.
>
> When I try to test/experiment with boss_flash, as described here
>
http://www.chicagoboss.org/api-session.html, I everything goes to
> shit. I think (know?) I'm doing something dumb, but after trying for
> too long (embarrassed to say how long!), I can't figure it out and
> decided to ask for help, so here I am.
>
> How do I use boss_flash? I just basically want to get to a Chicago
> Boss Sessions and Flash "hello world"! Thanks.
>
> Here are further details on my beginner's folly:
>
> I added this line:
> boss_flash:add(SessionID, notice, "Welcome!", "Your Session has now
> begun!").
>
> to this file:
> headliners_app_controller.erl
>
> so it now looks like this:
> -module(appname_my_controller, [Req, SessionID]).
> boss_flash:add(SessionID, notice, "Welcome!", "Your Session has now
> begun!").
>
> I added this line to a view file:
> {% for flash in boss_flash %} {{ flash.method }} - {{ flash.title }}
> - {{ flash.message }} {% endfor %}
>
> I restarted the server with:
> ./init-dev.sh
>
> And get this error:
> Error:
> {function_clause,
> [{erlydtl_runtime,init_counter_stats,
> [undefined,undefined],
> [{file,"src/erlydtl_runtime.erl"},{line,208}]},
> {headliners_app_view_search_index_html,render_internal,4,[]},
> {headliners_app_view_search_index_html,render,2,[]},
> {boss_web_controller,render_view,6,
> [{file,"src/boss/boss_web_controller.erl"},{line,836}]},
> {boss_web_controller,execute_action,5,
> [{file,"src/boss/boss_web_controller.erl"},{line,725}]},
> {boss_web_controller,execute_action,5,
> [{file,"src/boss/boss_web_controller.erl"},{line,727}]},
> {boss_web_controller,process_request,5,
> [{file,"src/boss/boss_web_controller.erl"},{line,459}]},
> {timer,tc,3,[{file,"timer.erl"},{line,194}]}]}
>
> I tried all the combinations of moving the code to different files
> (mainly just the controller for the particular view I wanted to show
> the flash message in) and either got the same error or the server (in
> the server shell window) seems to keep looping through "starting
> development server" (or whatever the exact wording is that it uses
> when it launches).
>
> Thanks,
> Chris
>