-
Notifications
You must be signed in to change notification settings - Fork 0
/
controller.rb
59 lines (49 loc) · 1.25 KB
/
controller.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
require( 'sinatra' )
require( 'sinatra/contrib/all' )
require( 'pry-byebug' )
require_relative( './models/transaction.rb' )
require_relative( './models/merchant.rb' )
require_relative( './models/tag.rb' )
require_relative( './models/quotes.rb')
get '/cashboard' do
@spend = Transaction.total_spent
@amount = Transaction.get_budget
erb (:index)
end
get '/cashboard/show' do
@transactions = Transaction.all
erb (:show)
end
get '/cashboard/add' do
@transaction = Transaction.all
@merchants = Merchant.all
@tags = Tag.all
erb (:add)
end
post '/cashboard' do
@transaction = Transaction.new(params)
@transaction.save
redirect '/success'
end
get '/success' do
@quotes = Quotes.all
erb (:success)
end
get '/cashboard/filter_tag' do
@transactions = Transaction.all
@tags = Tag.all
erb (:filter_tag)
end
get '/cashboard/filter_merchant' do
@transactions = Transaction.all
@merchants = Merchant.all
erb (:filter_merchant)
end
post '/cashboard/tag' do
@transactions = Transaction.find_by_tag(params["tag"])
erb(:show) # passing back to our table - why re create a table when we hae a perfectly good oene here
end
post '/cashboard/merchant' do
@transactions = Transaction.find_by_merchant(params["merchant"])
erb(:show)
end