search for: total_point

Displaying 3 results from an estimated 3 matches for "total_point".

Did you mean: total_points
2006 Jan 07
8
Using find_by_sql to get the sum of a column
...a newbie), I defined all sorts of methods only to discover that Rails (after reading Agile Web Dev) already had something much simpler (I don''t mind since it''s helping me learn Ruby along the way). My question is this, does Rails have any methods that can do this .. def self.total_points @points = self.find_by_sql("select sum(score) from scores") points = @points[0] #assigns first row points = points.attributes #assigns as hash points = points.values # pulls out the value points = points.to_s #converts to string points = points.to_i # converts to fixnum end Or am...
2006 Jun 08
5
Displaying Calculation on Index
Hi, I am trying to create a simple point system and display the total on my index page. So I have my db basically setup like this: Posts id, body, created_at, user_id Post_points id, post_id, user_id, created_at, value So as you can see I am allowing other users to create points on the post and my db will store who gave the point as well. "value" is the point value which can
2006 Jul 09
0
2 ActiveRecord Calculations
Hi, I am trying to use active record calculations to perform two calculations. 1. Get the sum for each group. 2. Of those groups, find the maximum number of that sum I have the first step done, I just can''t figure out the second step. Any ideas? Here is what I have right now: @total_points = BlahPoint.sum(''value'', :group => ''blah_id'') Then within my view I am calling: @total_points[blah.id] So as you can see, I have total points for each group (blah_id) and now I am trying to figure out how I can access the group with the most points. Tha...