forked from rgraff/sinatra-sequel-rspec
-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathapp.rb
34 lines (26 loc) · 819 Bytes
/
app.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
require "sinatra"
require_relative "config/init"
get "/posts/new" do
op = Post::Create.present({})
Post::Cell::New.(op, url: "/posts", layout: Gemgem::Cell::Layout).()
end
post "/posts" do
op = Post::Create.run(params) do |op|
redirect "/posts/#{op.model.id}"
end
Post::Cell::New.(op, url: "/posts", layout: Gemgem::Cell::Layout).()
end
get "/posts/:id" do
op = Post::Update.present(params)
Post::Cell::Show.(op.model, url: "/posts", layout: Gemgem::Cell::Layout).()
end
get "/posts/:id/edit" do
op = Post::Update.present(params)
Post::Cell::New.(op, url: "/posts/#{op.model.id}", layout: Gemgem::Cell::Layout).()
end
post "/posts/:id" do
op = Post::Update.run(params) do |op|
redirect "/posts/#{op.model.id}"
end
Post::Cell::Show.(op.model, layout: Gemgem::Cell::Layout).()
end