Wow! Thank you for the help.
I came to the same conclusions as you that just the B team games
counted...
I didn't know I do this "def games" definition ... I was looking for
that 3 months ago! Thank you.
I used the .uniq function to clean multiple occurence of teams and
games.
There probably is a better way to write the code below:
@games = []
listForTeams = @league.teams.uniq.dup
listForTeams.each do |t|
@games.concat(t.games)
end
@games.uniq!
I I has to change part of my code to deal with team.games as a function
and not an association.
For example, a replaced:
h[:gameplayed] = @games.find(:all, :conditions => ["team_a_id = (?) OR
team_b_id = (?)", t.id, t.id]).size()
by
gamesplayed = @games.select { |v| v.team_a_id == t.id || v.team_b_id ==
t.id }
h[:gamesplayed] = gamesplayed.size()
it works fine, I hope I'll have no problem going to an Ajax table with
those data.
Thanks again for your time.
Thierry
--
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
-~----------~----~----~----~------~----~------~--~---