Displaying 1 result from an estimated 1 matches for "visitor_stats".
2008 Dec 13
3
how to do "special queries" ala The Rails Way on "associated" conditions?
I have the following in a model class:
class Game < ActiveRecord::Base
	has_many :player_stats
	has_many :players, :through => :player_stats
	def visitor_stats
		stats = []
		player_stats.each do |stat|
			stats << stat	if stat.player.team.team_code ==
self.visiting_team_code
		end
		stats
	end
	def home_stats
		stats = []
		player_stats.each do |stat|
			stats << stat	if stat.player.team.team_code == self.home_team_code
		end
		stats
	end
en...