Hi Rick,
I want to do it exactly the way you are saying but I think I'm just a
bit confused here.
Let me show you what I'm working with now:
schedules = Schedule.find(:all, :joins => [:team, :opponent], :order =>
:team_id)
schedules.each do |schedule|
puts "Name = #{schedule.team.name} and ID = #{schedule.team.id} and
Opponent = #{schedule.opponent.id}"
end
I need to work out of schedules because there will be say 1,200 rows of
data. The teams table only contains 120 rows (for each team).
The associations I created were setup as:
class Schedule < ActiveRecord::Base
belongs_to :team
belongs_to :opponent, :class_name => "Team"
end
class Team < ActiveRecord::Base
has_many :schedules
has_many :inheritance_templates
has_many :opponents, :through => :schedules
has_many :tsos_offenses
has_many :tsos_defenses
has_many :tsos_steams
has_many :tsos_turnover_margins
has_many :tsrs_ratings
end
The above method does join both pieces together with teams. I'm just
unsure of how to iterate through them.
I tried what you said using opponent and even team as the next each
iteration but got no method each for those two..
--
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
-~----------~----~----~----~------~----~------~--~---