Rails Idioms + Django Templates + Erlang Power =
Chicago
BOSS
“Don’t you worry about that. You just let Boss worry about that.”

This trivial example demonstrates how to define, create, save, and display relational records for the obligatory blog application using Chicago Boss.

Model/blog_post.erl:

-module(blog_post, [Id, Title, Text, AuthorId]).
-compile(export_all).
-belongs_to(author).

Model/author.erl:

-module(author, [Id, Name]).
-compile(export_all).
-has_many(blog_posts).

Controller/blog_post_controller.erl:

-module(blog_post_controller, [Req]).
-compile(export_all).

create('GET', []) ->
    ok;
create('POST', []) ->
    FakeAuthor = (author:new(id, "Mark Twain")):save(),
    BlogPost = blog_post:new(id,
        Req:get_post_value("title"),
        Req:get_post_value("text"),
        FakeAuthor:id()),
    SavedBlogPost = BlogPost:save(),
    {redirect, "/blog_post/view/"++SavedBlogPost:id()}.

view('GET', [BlogPostId]) ->
    {ok, [{blog_post, boss_db:find(BlogPostId)}]}.

View/blog_post/create.html:

<form method="post">
Title: <input name="title"><br />
Text: <textarea name="text"></textarea><br />
<input type="submit">
</form>

View/blog_post/view.html:

<h1>{{ blog_post.title }}</h1>
By {{ blog_post.author.name }}
(Post #{{ blog_post.author.blog_posts|length }})
<p>{{ blog_post.text }}</p>

Database schema:

NONE

URL configuration file:

NONE