From dddedcf30f2350476713484838b21506353529d7 Mon Sep 17 00:00:00 2001 From: Jacob Cody Wimer Date: Fri, 24 Jan 2014 08:41:49 -0500 Subject: [PATCH] Created Pool 1 of 10 Man Bracket --- app/controllers/static_pages_controller.rb | 20 ++++++- app/models/school.rb | 9 +++ app/views/layouts/_header.html.erb | 2 +- app/views/schools/_form.html.erb | 8 +-- app/views/static_pages/_man10.html.erb | 55 +++++++++++++++++++ app/views/static_pages/brackets.html.erb | 3 + app/views/static_pages/weights.html.erb | 3 + config/routes.rb | 3 +- .../20140124015315_drop_school_score.rb | 5 ++ db/migrate/20140124021031_add_school_score.rb | 5 ++ db/schema.rb | 4 +- 11 files changed, 104 insertions(+), 13 deletions(-) create mode 100644 app/views/static_pages/_man10.html.erb create mode 100644 app/views/static_pages/brackets.html.erb create mode 100644 app/views/static_pages/weights.html.erb create mode 100644 db/migrate/20140124015315_drop_school_score.rb create mode 100644 db/migrate/20140124021031_add_school_score.rb diff --git a/app/controllers/static_pages_controller.rb b/app/controllers/static_pages_controller.rb index 68317c3..4927f15 100644 --- a/app/controllers/static_pages_controller.rb +++ b/app/controllers/static_pages_controller.rb @@ -4,8 +4,24 @@ class StaticPagesController < ApplicationController @tournaments = Tournament.all end - def school - @school = School.all + def brackets + if params[:weight] + @weight = Weight.find(params[:weight]) + @wrestlers = Wrestler.where(weight_id: @weight.id) + @seed1 = Wrestler.where(weight_id: @weight.id, original_seed: 1).first + end + #@seed1 = @wrestlers.where(original_seed: 1).name + + + end + + def weights + if params[:tournament] + @tournament = Tournament.find(params[:tournament]) + end + if @tournament + @weights = Weight.where(tournament_id: @tournament.id) + end end end diff --git a/app/models/school.rb b/app/models/school.rb index 3a89241..dee553a 100644 --- a/app/models/school.rb +++ b/app/models/school.rb @@ -1,4 +1,13 @@ class School < ActiveRecord::Base belongs_to :tournament has_many :wrestlers, dependent: :destroy + + #calculate score here + #def score + # @score = 0 + # self.wrestlers.each do |w| + # @score = @score + w.season_win * 2 + # end + # self.score = @score + #end end diff --git a/app/views/layouts/_header.html.erb b/app/views/layouts/_header.html.erb index d591e25..56fa9d4 100644 --- a/app/views/layouts/_header.html.erb +++ b/app/views/layouts/_header.html.erb @@ -6,7 +6,7 @@