diff --git a/app/controllers/debts_controller.rb b/app/controllers/debts_controller.rb new file mode 100644 index 0000000..97ad838 --- /dev/null +++ b/app/controllers/debts_controller.rb @@ -0,0 +1,7 @@ +class DebtsController < ApplicationController + def index + @debts = current_user.debts + end + + def update; end +end diff --git a/app/models/debt.rb b/app/models/debt.rb index 951347c..629bc51 100644 --- a/app/models/debt.rb +++ b/app/models/debt.rb @@ -2,4 +2,12 @@ class Debt < ApplicationRecord belongs_to :debtor, class_name: 'User' belongs_to :creditor, class_name: 'User' belongs_to :bet, optional: true + + def won_option + bet.options.winners.first + end + + def user_option(user) + user.user_bets.find_by(bet: bet).bet_option + end end diff --git a/app/views/debts/_my_debt.html.erb b/app/views/debts/_my_debt.html.erb new file mode 100644 index 0000000..3c8cdcd --- /dev/null +++ b/app/views/debts/_my_debt.html.erb @@ -0,0 +1,6 @@ + + <%= debt.creditor.username %> + $<%= debt.amount %> + <%= debt.won_option.option_text %> + <%= debt.user_option(current_user).option_text %> + diff --git a/app/views/debts/index.html.erb b/app/views/debts/index.html.erb new file mode 100644 index 0000000..00b2103 --- /dev/null +++ b/app/views/debts/index.html.erb @@ -0,0 +1,27 @@ +
+
+
+

Viewing my debts

+
+
+ +
+
+
+ + + + + + + + + + + <% @debts.each do |debt| %> + <%= render 'my_debt', debt: debt %> + <% end %> + +
I owethis muchbecauseand I bet on
+
+
diff --git a/app/views/debts/show.htlm.erb b/app/views/debts/show.htlm.erb new file mode 100644 index 0000000..e69de29 diff --git a/app/views/shared/_user_bar.html.erb b/app/views/shared/_user_bar.html.erb index bc92d01..e9286ce 100644 --- a/app/views/shared/_user_bar.html.erb +++ b/app/views/shared/_user_bar.html.erb @@ -13,6 +13,10 @@ +