From 7b3fe2aaad0eec9803b5171fa5438fa09f92168b Mon Sep 17 00:00:00 2001 From: Jacob Cody Wimer Date: Sat, 25 Apr 2015 13:59:59 -0400 Subject: [PATCH] Revert "Moving away from matchups_array and saving matches individually" This reverts commit 650a9ed7d639c5ab2b7284437e207c22f97a2866. --- app/models/match.rb | 9 -------- app/models/tournament.rb | 23 +++++-------------- app/views/layouts/_cdn.html.erb | 6 ----- app/views/static_pages/all_brackets.html.erb | 20 ++-------------- db/migrate/20150425173224_matchup_to_match.rb | 11 --------- db/schema.rb | 9 +++----- 6 files changed, 11 insertions(+), 67 deletions(-) delete mode 100644 db/migrate/20150425173224_matchup_to_match.rb diff --git a/app/models/match.rb b/app/models/match.rb index 9562f58..b1d59b8 100644 --- a/app/models/match.rb +++ b/app/models/match.rb @@ -2,13 +2,4 @@ class Match < ActiveRecord::Base belongs_to :tournament WIN_TYPES = ["Decision", "Major", "Tech Fall", "Pin", "Forfeit", "Injury Default", "Default", "DQ"] - - def w1_name - Wrestler.find(self.w1).name - end - - def w2_name - Wrestler.find(self.w2).name - end - end diff --git a/app/models/tournament.rb b/app/models/tournament.rb index b741c65..317b5b1 100644 --- a/app/models/tournament.rb +++ b/app/models/tournament.rb @@ -9,13 +9,12 @@ class Tournament < ActiveRecord::Base def upcomingMatches # @matches = generateMatchups - if self.matches.nil? - return self.matches + if self.matchups_array + return matchupHashesToObjects(self.matchups_array) else @matches = generateMatchups - puts @matches.inspect - saveMatchups(@matches) - return @matches + saveMatchups(@matches) + return @matches end end @@ -35,18 +34,8 @@ class Tournament < ActiveRecord::Base end def saveMatchups(matches) - matches.each do |m| - @match = Match.new - @match.w1 = m.w1 - @match.w2 = m.w2 - @match.round = m.round - @match.boutNumber = m.boutNumber - @match.bracket_position = m.bracket_position - @match.bracket_position_number = m.bracket_position_number - @match.tournament_id = self.id - puts @match.inspect - @match.save - end + self.matchups_array = matchupObjectsToHash(matches) + self.save end diff --git a/app/views/layouts/_cdn.html.erb b/app/views/layouts/_cdn.html.erb index 01039df..53233c9 100644 --- a/app/views/layouts/_cdn.html.erb +++ b/app/views/layouts/_cdn.html.erb @@ -9,11 +9,5 @@ - - - - - - diff --git a/app/views/static_pages/all_brackets.html.erb b/app/views/static_pages/all_brackets.html.erb index 8e712e6..fecebfc 100644 --- a/app/views/static_pages/all_brackets.html.erb +++ b/app/views/static_pages/all_brackets.html.erb @@ -3,26 +3,11 @@ #html, #body, #wrapper { width:100%; } - - + <%= link_to "Back to #{@tournament.name} weights", "/static_pages/weights?tournament=#{@tournament.id}" %>

- - -
-
-
<% @tournament.weights.sort_by{|w| w.max}.each do |w| %>
<% @weight = w %> @@ -47,5 +32,4 @@ <%= render 'fourPoolSemiBracket' %> <% end %>
-<% end %> -
\ No newline at end of file +<% end %> \ No newline at end of file diff --git a/db/migrate/20150425173224_matchup_to_match.rb b/db/migrate/20150425173224_matchup_to_match.rb deleted file mode 100644 index 34170e3..0000000 --- a/db/migrate/20150425173224_matchup_to_match.rb +++ /dev/null @@ -1,11 +0,0 @@ -class MatchupToMatch < ActiveRecord::Migration - def change - add_column :matches, :weight_id, :integer - add_column :matches, :bracket_position, :string - add_column :matches, :bracket_position_number, :integer - rename_column :matches, :r_id, :w1 - rename_column :matches, :g_id, :w2 - - - end -end diff --git a/db/schema.rb b/db/schema.rb index e0374b7..e7a4408 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -11,11 +11,11 @@ # # It's strongly recommended that you check this file into your version control system. -ActiveRecord::Schema.define(version: 20150425173224) do +ActiveRecord::Schema.define(version: 20150328183257) do create_table "matches", force: :cascade do |t| - t.integer "w1" - t.integer "w2" + t.integer "r_id" + t.integer "g_id" t.text "g_stat" t.text "r_stat" t.integer "winner_id" @@ -27,9 +27,6 @@ ActiveRecord::Schema.define(version: 20150425173224) do t.integer "round" t.integer "finished" t.integer "boutNumber" - t.integer "weight_id" - t.string "bracket_position" - t.integer "bracket_position_number" end create_table "mats", force: :cascade do |t|