From c14e35bb506c14564f89e25c66ef60f0bd472715 Mon Sep 17 00:00:00 2001 From: "Jesse C. Fisher" Date: Mon, 4 Nov 2019 03:54:06 -0800 Subject: [PATCH] Fix New Game button --- app/controllers/tables_controller.rb | 3 ++- app/models/game.rb | 4 +++- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/app/controllers/tables_controller.rb b/app/controllers/tables_controller.rb index a6ebdf8c..f021ac9d 100644 --- a/app/controllers/tables_controller.rb +++ b/app/controllers/tables_controller.rb @@ -40,7 +40,8 @@ class TablesController < ApplicationController end def new_game - @table.add_game + @game = @table.add_game + @game.start redirect_to @table end diff --git a/app/models/game.rb b/app/models/game.rb index 8f7b251c..00376722 100644 --- a/app/models/game.rb +++ b/app/models/game.rb @@ -182,8 +182,10 @@ private self.table ||= Table.create current_game_id: self.id self.seats = self.table.seats self.seats.each do |seat| - if seat.user_id || seat.user_soft_token + if (seat.user_id || seat.user_soft_token) new_player = self.players.create(user_id: seat.user_id, soft_token: seat.user_soft_token) + seat.player = new_player + seat.save end end self.save