-
Notifications
You must be signed in to change notification settings - Fork 2
/
main.rb
58 lines (46 loc) · 1.15 KB
/
main.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
require 'pry'
require 'sinatra'
require 'sinatra/reloader' if development?
require_relative 'database_config'
require 'bcrypt'
also_reload File.expand_path(__dir__, 'models/*') if development?
also_reload File.expand_path(__dir__, 'views/*') if development?
also_reload File.expand_path(__dir__, 'routes/*') if development?
require_relative 'models/answer'
require_relative 'models/business'
require_relative 'models/category'
require_relative 'models/comment'
require_relative 'models/listing'
require_relative 'models/message'
require_relative 'models/user'
enable :sessions
helpers do
def logged_in?
if current_user
return true
else
return false
end
end
def current_user
User.find_by(id: session[:user_id])
end
end
after do
ActiveRecord::Base.connection.close
end
get '/' do
erb :index
end
get '/about' do
erb :about
end
require_relative 'routes/accounts'
require_relative 'routes/listings'
require_relative 'routes/maps'
require_relative 'routes/messages'
require_relative 'routes/questions'
require_relative 'routes/answers'
require_relative 'routes/sessions'
# require_relative 'email'
require_relative 'routes/email'