Okay I just want to make sure I understand this better.

schedules = Schedule.find(:all)
schedules.each do |schedule|
  puts "Team Id = #{schedule.team_id}"
end

That shows me all the team_ids listed in the schedules table.  Now what 
if I want to iterate through those team_ids and collect all of their 
opponent ids together?

team Id 1 -> Opponent Id 3
team Id 1 -> Opponent Id 94
etc.

Each team has more than one opponent scheduled.  The id fields are 
team_id and opponent_id.

I tried:

schedules = Schedule.find(:all)
schedules.each do |schedule|
  schedule.team_id.each do |team|
    puts "Team Id = #{schedule.team_id} and Opponent Id = 
#{team.opponent_id}"
  end
end

But that will give me no method each found for 6:fixnum because I'm 
trying each on a team_id number..

How do I further iterate through each row returned to gather up the 
data?  I want to know what opponent_ids each team_id has.
-- 
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