From 327e50b197abf6c8392cac9e9e71983f8dc934c5 Mon Sep 17 00:00:00 2001 From: "Jesse C. Fisher" Date: Tue, 29 Oct 2019 03:10:40 -0700 Subject: [PATCH] Fix player count in table index, adds user_count to table --- app/models/table.rb | 3 +++ app/views/tables/index.html.haml | 2 +- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/app/models/table.rb b/app/models/table.rb index 3cb983ad..88537421 100644 --- a/app/models/table.rb +++ b/app/models/table.rb @@ -22,6 +22,9 @@ class Table < ActiveRecord::Base where(game:nil).last || Table.create(title: "Table " + user.soft_token[0..4]) } + def user_count + self.seats.map{|s| s.occupied? ? s : nil}.compact.count + end def current_game self.games.last diff --git a/app/views/tables/index.html.haml b/app/views/tables/index.html.haml index 6541e082..55e40bad 100644 --- a/app/views/tables/index.html.haml +++ b/app/views/tables/index.html.haml @@ -6,7 +6,7 @@ - @tables.each do |table| .table .title= link_to table.title, table - .player-count= "#{table.users.count} Players" + .player-count= "#{table.user_count} Players" - if policy(table).update? .owner-controls