forked from makersacademy/chitter-challenge
-
Notifications
You must be signed in to change notification settings - Fork 0
/
app.rb
38 lines (30 loc) · 728 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
35
36
37
38
# frozen_string_literal: true
require 'sinatra/base'
require 'sinatra/reloader'
require 'rack'
require './lib/quack'
# DuckBoard class is the controller
class DuckBoard < Sinatra::Base
enable :sessions
configure :development do
register Sinatra::Reloader
end
get '/' do
@quacks = Quack.all
erb :index
end
post '/name' do
session[:display_name] = params[:display_name]
redirect '/compose_quack'
end
get '/compose_quack' do
@display_name = session[:display_name]
@quacks = Quack.all
erb :compose_quack
end
post '/message' do
Quack.create(message: params[:message], display_name: session[:display_name])
redirect '/'
end
run! if app_file == $PROGRAM_NAME
end