On Sun, Jul 19, 2009 at 10:01 PM, Älphä Blüë
<[email protected]> wrote:
>
> http://pastie.org/551660
>
>
I haven't investigated all of this, and I'm coming from a Java/Groovy
background and new to Rails, but when I see 120.times to me it throws
up a red flag. Can't you make this more OO? For example I would think
you could say Find all teams and for each team there would be a
collection of "opponents." (I remember a while back we had a
discussion on the model for this project but forgot how it was
resolved.)
I would think the query itself would take care of a lot of this to
avoid certain array constructs. I'd think lines 10-13 would just
become teams = Teams.find(:all) (where in each time you'd have
collection opponents )
Then later, something like:
teams.each do |team|
val = 0
team.opponents.each do |opponent|
if opponent.schedule_id == 121
val += 0.2511
else
val += opp_off_tsos[opponent.id]
end
end
end
Maybe I'm missing something (and I'm sure I am) but it sure seems
cleaner using nested collections than doing all that array stuff.
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---