diff --git a/app/controllers/static_pages_controller.rb b/app/controllers/static_pages_controller.rb
index 1a20c50..e60c5b0 100644
--- a/app/controllers/static_pages_controller.rb
+++ b/app/controllers/static_pages_controller.rb
@@ -8,10 +8,8 @@ class StaticPagesController < ApplicationController
@tournament = Tournament.find(params[:tournament])
end
if @tournament
- @matches = Match.where(tournament_id: @tournament.id)
+ @bouts = @tournament.bouts
end
- @matches = @matches.where(finished: nil)
-
end
def results
if params[:tournament]
diff --git a/app/models/bout.rb b/app/models/bout.rb
new file mode 100644
index 0000000..8a0a4b3
--- /dev/null
+++ b/app/models/bout.rb
@@ -0,0 +1,11 @@
+class Bout
+ attr_accessor :w1, :w2, :tournament_id
+ def self.all
+ ObjectSpace.each_object(self).to_a
+ end
+
+ def self.count
+ all.count
+ end
+
+end
\ No newline at end of file
diff --git a/app/models/pool.rb b/app/models/pool.rb
new file mode 100644
index 0000000..322ac55
--- /dev/null
+++ b/app/models/pool.rb
@@ -0,0 +1,30 @@
+class Pool
+ def createPool(tournament)
+ @weights = Weight.where(tournament_id: tournament)
+ @weights.each do |weight|
+ roundRobin(weight,tournament)
+ end
+ end
+
+ def createBout(wrestler,tournament)
+ @bout = Bout.new
+ @bout.w1 = wrestler.id
+ @bout.tournament_id = tournament
+ end
+
+ def roundRobin(weight,tournament)
+ @wrestlers = Wrestler.where(weight_id: weight)
+ @wrestlers.each do |wrestler|
+ createBout(wrestler,tournament)
+ end
+ end
+
+ def self.all
+ ObjectSpace.each_object(self).to_a
+ end
+
+ def self.count
+ all.count
+ end
+
+end
\ No newline at end of file
diff --git a/app/models/tournament.rb b/app/models/tournament.rb
index 43e7045..cbb3a97 100644
--- a/app/models/tournament.rb
+++ b/app/models/tournament.rb
@@ -3,4 +3,11 @@ class Tournament < ActiveRecord::Base
has_many :weights, dependent: :destroy
has_many :matches, dependent: :destroy
has_many :mats, dependent: :destroy
+
+ def bouts
+ @pool = Pool.new
+ @pool.createPool(self.id)
+ @bouts = Bout.all
+ return @bouts
+ end
end
diff --git a/app/models/weight.rb b/app/models/weight.rb
index 8ea7bd1..263ba88 100644
--- a/app/models/weight.rb
+++ b/app/models/weight.rb
@@ -1,4 +1,6 @@
class Weight < ActiveRecord::Base
belongs_to :tournament
has_many :wrestlers, dependent: :destroy
+
+
end
diff --git a/app/views/static_pages/up_matches.html.erb b/app/views/static_pages/up_matches.html.erb
index ea3702e..3b263e6 100644
--- a/app/views/static_pages/up_matches.html.erb
+++ b/app/views/static_pages/up_matches.html.erb
@@ -1,45 +1,8 @@
<%= link_to "Back to #{@tournament.name}", "/tournaments/#{@tournament.id}" %>
-