If @average_stat is Stat.new then @average_stat.points,
@average_stat.assists, etc... are also integer. So you could use a
array variable, after stats = Stat.find(:all) :
@average_stat=[ stats.sum('points') / stats.count('points'),
stats.sum('assists') / stats.count('assists') , stats.sum('blocks') /
stats.count('blocks') , stats.sum('turnovers') /
stats.count('turnovers') ] .
In fact you shoud use directly average(stat.points), etc.. See
http://api.rubyonrails.org/classes/ActiveRecord/Calculations/ClassMethods.html#M002188
--
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.