Guest User

Untitled

a guest
Oct 27th, 2017
86
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Erlang 0.47 KB | None | 0 0
  1. post('GET', [], Account) ->
  2.     {ok, [{account, Account}]};
  3.    
  4. post('POST', [], Account) ->
  5.     Title = Req:post_param("title"),
  6.     Body = Req:post_param("body"),
  7.     Post = post:new(id, Title, Account:id(), Body, erlang:now(), erlang:now()),
  8.     case Post:save() of
  9.         {ok, SavedPost} ->
  10.             boss_flash:add(SessionId, success, "Success", "Great, your new post was published."),
  11.             {redirect, "/account/posts"};
  12.         {error, ErrorMessage} ->
  13.             io:format("Not saved"),
  14.             {ok, []}
  15.     end.
Add Comment
Please, Sign In to add comment