Hello

I have few typical models:

class Team < AR::Base
  has_many :games
end

class Game < AR::Base
  belongs_to :team
  has_many :events
end

etc..

When I list the team.games I want to be able to aggregate some of the
data (games won, lost etc).  I could do this using scopes, but there are
so many different calculations it would result in a lot of queries.

As I am already fetching all the team games in one DB call, should I be
doing the calculations using just plain ruby on the fly, or even on the
client side using JSON/JS?  Or is it better in fact to push everything
through SQL.

I'm not sure of the best plan of attack to do these calculations given
that they could well involve pulling data from the children of each game
as well (e.g events).

Many thanks in advance for any insight.  I am pulling my hair out here!

Cameron

-- 
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