Rick,

I was also looking at your example - this is what I would like to do:

schedules = Schedule.find(:all, :joins => [:team, :opponent, 
:tsos_offense], :order => :team_id)
schedules.each do |schedule|
  val = 0
  schedule.opponents.each do |opponent|
    if opponent.id == nil
      val += 0.2511
    else
      val += schedule.tsos_offenses.totals
      puts "Team name = #{schedule.team.name} and opp_id = 
#{schedule.opponent.id} and sum of val now = #{val} pulled from original 
value of #{schedule.tsos_offense.totals}."
    end
    puts "Team"
  end
end

When it comes down to it, each team, opponent has a ratings assigned to 
team_id in tsos_offense.  So, couldn't I just somehow join the ratings 
tables with schedules and setup all the information side by side and 
iterate through it?

Example diagram:

Team has ..

id
name

Schedule has ..

team_id
opponent_id

Tsos Offense has ..

team_id
totals

======================================
Name | team_id | opponent_id | totals
======================================

What would I have to do in tsos_offense to make the association work and 
is my loop above correct once the association is in place?

-- 
Posted via http://www.ruby-forum.com/.

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Talk" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to