-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapp.rb
executable file
·65 lines (51 loc) · 1.14 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
require 'sinatra'
require "sinatra/activerecord"
#RACK_ENV=production rackup config.ru
set :database, "sqlite3:///to_do_class_app.db"
get "/favorite_movies" do
@favs = FavoriteMovie.all
erb :"fav_mov/index"
end
get "/error" do
"whoopsies try again"
end
get "/addition" do
erb :"fav_mov/addition_index"
end
# put "/edit/:id" do
# @favs = FavoriteMovie.find(params[:id])
# end
get "/edit/:id" do
@movie_to_remove = FavoriteMovie.find(params[:id])
erb :"fav_mov/show"
end
delete "/edit/:id" do
@movie_to_remove = FavoriteMovie.find(params[:id])
@movie_to_remove.delete
redirect "./favorite_movies"
end
get "/remove" do
@favs = FavoriteMovie.all
erb :"fav_mov/remove_index"
end
post "/add_post" do
movie = FavoriteMovie.new
movie.title = params[:mov_name]
movie.description = params[:mov_desc]
movie.save
redirect "./favorite_movies"
end
# post "/favs" do
# name = params[:mov_name]
# description = params[:mov_desc]
# movie = {name => description}
# Favorites.add_mov(movie)
# redirect "./fav_mov_app"
# end
class FavoriteMovie < ActiveRecord::Base
def add_movie
## validations
end
end
class Deer < ActiveRecord::Base
end