ActiveRecord Calculations 4
I've been wanting to modify the ActiveRecord Calculations module to support multiple aggregate calculations in one query for awhile now. My current project with lots of graphing finally gave me the motivation to do it. Refer to the patch for details and feel free to comment on it.
# Calculate different aggregate functions at once
min, max = Person.calculate(:min, :age, :max, :age)
# Specify the column aliases so you can order by it
views, replies = Posts.sum({:views => 'number_of_views'}, :replies, :order => "number_of_views desc")
Multiple Calculations Patch