1
0
mirror of https://github.com/jcwimer/wrestlingApp synced 2026-04-18 21:42:16 +00:00

Trying to remove queries and rely on associations

This commit is contained in:
2015-11-02 13:25:53 -05:00
parent f14fbadfd1
commit e426a491b3
3 changed files with 7 additions and 7 deletions

View File

@@ -2,6 +2,7 @@ class Wrestler < ActiveRecord::Base
belongs_to :school
belongs_to :weight
has_one :tournament, through: :weight
has_many :matches, through: :weight
attr_accessor :poolNumber
before_save do
@@ -44,7 +45,7 @@ class Wrestler < ActiveRecord::Base
end
def allMatches
@matches = Match.where("w1 = ? or w2 = ?",self.id,self.id)
@matches = matches.select{|m| m.w1 == self.id or m.w2 == self.id}
return @matches
end