-
Notifications
You must be signed in to change notification settings - Fork 0
/
app.rb
81 lines (66 loc) · 1.42 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
74
75
76
77
78
79
80
require 'sinatra'
require 'sinatra/reloader'
require 'pony'
require './database.rb'
get '/' do
erb :home
end
get '/work_history' do
erb :work_history
end
get '/contact' do
erb :contact
end
post '/contact' do
Pony.mail(:to => 'your-email-address',
:from => params[:message][:email],
:subject => params[:message][:subject],
:body => params[:message][:content],
:via => :smtp,
:smtp => {
:host => "your host", #ex "smtp.gmail.com"
:port => 'port-number', #ex 587
:user => 'your-login-credentials',
:password => 'your-pasword',
:auth => :plain,
:domain => "Your domain"
})
redirect "/"
end
#jobs routes
get '/jobs' do
@jobs = Job.all
erb :'jobs/index'
end
get '/jobs/new' do
erb :'jobs/new'
end
post '/jobs/new' do
job = Job.new(params[:job])
if job.save
redirect "/jobs/#{job.id}"
else
redirect '/jobs/new'
end
end
get '/jobs/:id' do
@job = Job.find(params[:id])
erb :'jobs/show'
end
get '/jobs/:id/edit' do
@job = Job.find(params[:id])
erb :'jobs/edit'
end
post '/jobs/:id/edit' do
job = Job.find(params[:id])
if job.update_attributes(params[:job])
redirect "/jobs/#{job.id}"
else
redirect "/jobs/#{job.id}/edit"
end
end
get '/jobs/:id/destroy' do
job = Job.find(params[:id])
job.destroy
redirect '/jobs'
end