17 Nov '12, 8am

How to group by a range of values in ActiveRecord (ruby on rails)?

I have an ActiveRecord model that has two columns I want to group and sum by (both are integers). The issue I can't seem to solve is how to sum the first column as a group of the second column, with the second column being grouped by a range. I know that I can do Model.sum(:first_column, group: :second_column), but this results in many groups, because the second columns values are spread out. How can I group the second columns' values, e.g. in ranges of 10 (0-9, 10-19, 20-29, etc.)?

Full article: http://stackoverflow.com/questions/13428409/how-to-group-...

Tweets

#Jobs #jobsite Ruby on Rails Developer - London...

fishajob.co.uk 16 Nov '12, 6am

Ruby on Rails Developer - London - 6 months - Explore Group - London Tue, 13 Nov 2012 04:30:47 GMT Ruby on Rails Developer...

New post: "Ruby on Rails Developer" #jobs #Melb...

jobsense.com.au 17 Nov '12, 3am

VIC-Melbourne, Back and front end development CBD location Three month contract Government department This government depa...

Want to work on Ruby on Rails at NZX in Welling...

nzxgroup.com 21 Nov '12, 11pm

NZX provides an excellent range of experiences and opportunities to broaden your skill base across legal, strategic, IT in...

This Week in Ruby: MRI 1.9.3-p327, Rails 3.2.9,...

rubyinside.com 15 Nov '12, 4pm

Welcome to this week’s roundup of Ruby news, articles, videos, and more, cobbled together from my e-mail newsletter, Ruby ...

Ruby on Rails existing website customization, r...

freelancer.com 12 Nov '12, 3pm

Project ID: 2641506 Project Type: Fixed Project Description: We are looking for a Ruby on Rails expert (plus heroku deploy...