From 12d9683cff87fe54e246a5b081b71e79351b0662 Mon Sep 17 00:00:00 2001 From: YarekTenko Date: Tue, 7 Mar 2017 09:41:20 -0800 Subject: [PATCH] Add Paginator to BetsController --- app/controllers/bets_controller.rb | 5 ++++- app/views/bets/_display_bets.html.erb | 14 +++++++++++++- app/views/bets/index.html.erb | 13 ++++++++++++- 3 files changed, 29 insertions(+), 3 deletions(-) diff --git a/app/controllers/bets_controller.rb b/app/controllers/bets_controller.rb index 4211b51..3b0e2e3 100644 --- a/app/controllers/bets_controller.rb +++ b/app/controllers/bets_controller.rb @@ -1,6 +1,9 @@ class BetsController < ApplicationController + include Utilities::Paginator + helper_method :paginator + def index - @bets = Bet.all + @bets = items_to_display(item: Bet, items_per_page: 25) end def show diff --git a/app/views/bets/_display_bets.html.erb b/app/views/bets/_display_bets.html.erb index 37c7d69..10de468 100644 --- a/app/views/bets/_display_bets.html.erb +++ b/app/views/bets/_display_bets.html.erb @@ -5,10 +5,22 @@ Created By Created at + Expires at Total amount bet - Bet description + Bet description + + <% bets.each do |bet| %> + + <%= bet.creator_id %> + <%= bet.created_at %> + <%= bet.expires_at %> + <%= bet.bet_total %> + <%= bet.bet %> + + <% end %> + diff --git a/app/views/bets/index.html.erb b/app/views/bets/index.html.erb index 7ade0da..13f2bd7 100644 --- a/app/views/bets/index.html.erb +++ b/app/views/bets/index.html.erb @@ -5,5 +5,16 @@

This page will display all the existing bets (25/page) and allow the user to use custom search criteria.

- <%= render 'bets/display_bets' %> +
+
+ <%= render 'display_bets', bets: @bets %> +
+
+ +
+
<% end %>