1
0
mirror of https://github.com/jcwimer/wrestlingApp synced 2026-03-25 01:14:43 +00:00

Trying to increase speed of up_matches

This commit is contained in:
2015-11-02 10:55:41 -05:00
parent 02a791da2a
commit c0760dfdf8
3 changed files with 17 additions and 8 deletions

View File

@@ -2,6 +2,7 @@ class Match < ActiveRecord::Base
belongs_to :tournament
belongs_to :weight
belongs_to :mat
has_many :wrestlers, :through => :weight
after_save do
if self.finished == 1
@@ -30,6 +31,14 @@ class Match < ActiveRecord::Base
end
end
def wrestler1
wrestlers.where(id: self.w1)
end
def wrestler2
wrestlers.where(id: self.w2)
end
def w1_name
if self.w1
Wrestler.find(self.w1).name