diff --git a/app/models/match.rb b/app/models/match.rb index ebcd1ef..2d5d274 100644 --- a/app/models/match.rb +++ b/app/models/match.rb @@ -4,12 +4,12 @@ class Match < ActiveRecord::Base belongs_to :mat, touch: true has_many :wrestlers, :through => :weight - - after_update do + + after_update do after_update_actions end - + def after_update_actions if self.finished == 1 && self.winner_id != nil if self.w1 && self.w2 @@ -30,9 +30,9 @@ class Match < ActiveRecord::Base if self.w1 && self.w2 wrestler1.school.calcScore wrestler2.school.calcScore - end + end end - + def mat_assigned if self.mat @@ -41,7 +41,7 @@ class Match < ActiveRecord::Base "" end end - + def pinTime if self.win_type == "Pin" time = self.score.delete("") @@ -54,7 +54,7 @@ class Match < ActiveRecord::Base end def advance_wrestlers - if self.w1 && self.w2 + if self.w1 && self.w2 AdvanceWrestler.new(wrestler1).advance AdvanceWrestler.new(wrestler2).advance end @@ -117,7 +117,7 @@ class Match < ActiveRecord::Base def weight_max self.weight.max end - + def replaceLoserNameWithWrestler(w,loserName) if self.loser1_name == loserName self.w1 = w.id @@ -133,6 +133,12 @@ class Match < ActiveRecord::Base wrestler1.pool end end - + def list_w2_stats + "#{w2_name}: #{w2_stat}" + end + + def list_w1_stats + "#{w1_name}: #{w1_stat}" + end end diff --git a/app/views/wrestlers/show.html.erb b/app/views/wrestlers/show.html.erb index 4a7efb9..b71b3b8 100644 --- a/app/views/wrestlers/show.html.erb +++ b/app/views/wrestlers/show.html.erb @@ -1,22 +1,22 @@ - + <%= link_to "Back to #{@school.name}", "/schools/#{@school.id}", :class=>"btn btn-default" %> <% if can? :manage, @school %> | <%= link_to "Edit #{@wrestler.name}", edit_wrestler_path(@wrestler), :class=>"btn btn-primary" %> <% end %> -<% cache ["#{@wrestler.id}", @wrestler] do %> +<% cache ["#{@wrestler.id}", @wrestler] do %>

Name: <%= @wrestler.name %>

- +

School: <%= @wrestler.school.name %>

- +

Weight: <%= @wrestler.weight.max %> @@ -33,12 +33,18 @@ Total Team Points Scored: <%= @wrestler.totalTeamPoints %>

- +

Matches


<% @wrestler.allMatches.each do |m| %> -
Bout: <%= m.bout_number %> <%= m.bracket_position %> <%= m.wrestler1.name %> vs. <%= m.wrestler2.name %> <%= @wrestler.resultByBout(m.bout_number) %>
+
Bout: <%= m.bout_number %> <%= m.bracket_position %> <%= m.wrestler1.name %> vs. <%= m.wrestler2.name %> <%= @wrestler.resultByBout(m.bout_number) %>
+ <% if m.w1_stat || m.w2_stat %> +
Stats:
+
<%= m.list_w1_stats %>
+
<%= m.list_w2_stats %>
+
+ <% end %> <% end %> -<% end %> \ No newline at end of file +<% end %>