From aa6e8f12a24e33d88a5751cee5e93bf4a038e2ef Mon Sep 17 00:00:00 2001 From: Tomer Kimia Date: Tue, 1 Apr 2014 18:51:03 -0400 Subject: AJAX is now working in the tournament loading page --- app/controllers/tournaments_controller.rb | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) (limited to 'app/controllers') diff --git a/app/controllers/tournaments_controller.rb b/app/controllers/tournaments_controller.rb index 2f04e1f..4455ad2 100644 --- a/app/controllers/tournaments_controller.rb +++ b/app/controllers/tournaments_controller.rb @@ -11,10 +11,20 @@ class TournamentsController < ApplicationController # GET /tournaments/1 # GET /tournaments/1.json def show - case @tournament.status - when 0 - when 1..2 - redirect_to "/tournaments/" + @tournament.id.to_s + "/matches" #tournament_matches_page(@tournament) + respond_to do |format| + format.html { + case @tournament.status + when 0 + render action: 'show' + when 1..2 + redirect_to "/tournaments/" + @tournament.id.to_s + "/matches" #tournament_matches_page(@tournament) + end + } + format.json { + data = JSON.parse(@tournament.to_json) + data["players"] = @tournament.players; + render :json => data.to_json + } end end -- cgit v1.2.3-2-g168b