diff --git a/app/controllers/static_pages_controller.rb b/app/controllers/static_pages_controller.rb index 0a89ead..fe35a08 100644 --- a/app/controllers/static_pages_controller.rb +++ b/app/controllers/static_pages_controller.rb @@ -33,7 +33,6 @@ class StaticPagesController < ApplicationController end def brackets - if params[:weight] @weight = Weight.find(params[:weight]) @bracketType = @weight.pool_bracket_type @@ -41,8 +40,6 @@ class StaticPagesController < ApplicationController @matches = @tournament.upcomingMatches.select{|m| m.weight_id == @weight.id} @wrestlers = Wrestler.where(weight_id: @weight.id) end - - end def weights @@ -54,5 +51,4 @@ class StaticPagesController < ApplicationController @weights = @weights.sort_by{|x|[x.max]} end end - end diff --git a/app/models/school.rb b/app/models/school.rb index 97585d0..0c9ff6b 100644 --- a/app/models/school.rb +++ b/app/models/school.rb @@ -1,29 +1,11 @@ class School < ActiveRecord::Base belongs_to :tournament has_many :wrestlers, dependent: :destroy + attr_accessor :score #calculate score here def score - @score = 0 - self.wrestlers.each do |wrestler| - @match_wins = Match.where(winner_id: wrestler.id) - @match_wins.each do |m| - @score = @score + 2 - if m.win_type == "Major" - @score = @score + 1 - elsif m.win_type == "Tech Fall" - @score = @score + 1.5 - elsif m.win_type == "Pin" - @score = @score + 2 - elsif m.win_type == "Forfeit" - @score = @score + 2 - elsif m.win_type == "Injury Default" - @score = @score + 2 - elsif m.win_type == "Default" - @score = @score + 2 - end - end - end - self.score = @score + @matches = self.tournament.upcomingMatches + return 0 end end diff --git a/db/migrate/20150328183257_drop_school_score_again.rb b/db/migrate/20150328183257_drop_school_score_again.rb new file mode 100644 index 0000000..82e0f7e --- /dev/null +++ b/db/migrate/20150328183257_drop_school_score_again.rb @@ -0,0 +1,5 @@ +class DropSchoolScoreAgain < ActiveRecord::Migration + def change + remove_column :schools, :score + end +end diff --git a/db/schema.rb b/db/schema.rb index 79e0e4b..e7a4408 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -11,7 +11,7 @@ # # It's strongly recommended that you check this file into your version control system. -ActiveRecord::Schema.define(version: 20150325004527) do +ActiveRecord::Schema.define(version: 20150328183257) do create_table "matches", force: :cascade do |t| t.integer "r_id" @@ -41,7 +41,6 @@ ActiveRecord::Schema.define(version: 20150325004527) do t.datetime "created_at" t.datetime "updated_at" t.integer "tournament_id" - t.integer "score" end create_table "tournaments", force: :cascade do |t|