Rails 3 and mongoid: How would you about sorting / grouping collect to display as a 2 dimension table? Rails 3 and mongoid: How would you about sorting / grouping collect to display as a 2 dimension table? mongodb mongodb

Rails 3 and mongoid: How would you about sorting / grouping collect to display as a 2 dimension table?


The general answer here is to perform a Map / Reduce. Generally, you do not perform the map-reduce in real time due to performance constraints. Instead you run the map-reduce on a schedule and query against the results directly.

Here's a primer on map-reduce for Ruby. Here's another example using Mongoid specifically.