-
Notifications
You must be signed in to change notification settings - Fork 2
/
app.rb
73 lines (55 loc) · 1.2 KB
/
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
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
require "roda"
require "tus/server"
require "./models/movie"
class ShrineTusDemo < Roda
plugin :public
plugin :render
plugin :partials
plugin :forme
plugin :assets, js: "app.js", css: "app.css"
use Rack::MethodOverride
plugin :all_verbs
plugin :indifferent_params
# serve tus files through frontend server
use Rack::Sendfile
# log requests
use Rack::CommonLogger
route do |r|
r.public # serve static assets
r.assets # serve dynamic assets
r.on "files" do
r.run Tus::Server
end
r.root do
r.redirect "/movies"
end
r.on "movies" do
r.get true do
@movies = Movie.all
view("movies/index")
end
r.get "new" do
@movie = Movie.new
view("movies/new")
end
r.post true do
movie = Movie.create(params[:movie])
r.redirect "/movies"
end
r.on Integer do |id|
@movie = Movie[id]
r.get "edit" do
view("movies/edit")
end
r.put do
@movie.update(params[:movie])
r.redirect "/movies"
end
r.delete do
@movie.destroy
r.redirect "/movies"
end
end
end
end
end