1
0
mirror of https://github.com/jcwimer/wrestlingApp synced 2026-03-25 01:14:43 +00:00

Refactored generating matches

This commit is contained in:
2015-05-26 18:27:55 +00:00
parent 81f233cb0e
commit 9d8e0850bc
2 changed files with 10 additions and 11 deletions

View File

@@ -87,15 +87,15 @@ class StaticPagesController < ApplicationController
end end
def generate_matches def generate_matches
if user_signed_in? if !user_signed_in?
else
redirect_to root_path redirect_to root_path
end elsif user_signed_in?
if params[:tournament] if params[:tournament]
@tournament = Tournament.find(params[:tournament]) @tournament = Tournament.find(params[:tournament])
end end
if @tournament if @tournament
@tournament.generateMatchups @tournament.generateMatchups
end end
end
end end
end end

View File

@@ -13,7 +13,7 @@ class Tournament < ActiveRecord::Base
@matches = Match.where(tournament_id: self.id) @matches = Match.where(tournament_id: self.id)
end end
def createCustomWeights(value) def createCustomWeights(value)
self.weights.destroy_all self.weights.destroy_all
if value == 'hs' if value == 'hs'
@weights = [106,113,120,132,138,145,152,160,170,182,195,220,285] @weights = [106,113,120,132,138,145,152,160,170,182,195,220,285]
@@ -30,7 +30,6 @@ class Tournament < ActiveRecord::Base
if matches.nil? if matches.nil?
return nil return nil
else else
generateMatchups
matches matches
end end
end end