Forum: Ruby on Rails sub-totals in tables

Announcement (2017-05-07): is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see and for other Rails- und Ruby-related community platforms.
44a43e7fef8e933e802a7802b4bd3525?d=identicon&s=25 John Small (johnsmall)
on 2009-05-19 15:57
How can I get sub-totalling in tables?

I have an ActiveResource model which gets it's data from a legacy
Windows app via REST. The records are ordered by date. I need to display
subtotals by week number. It looks like I'll have to code something,
which isn't a problem, but this is such a common pattern someone must
have done something before me.

Any clues?

John Small
3131fcea0a711e5ad89c8d49cc9253b4?d=identicon&s=25 Julian Leviston (Guest)
on 2009-05-19 19:07
(Received via mailing list)
On 19/05/2009, at 11:57 PM, John Small <rails-mailing-list@andreas-> wrote:

> Any clues?
> John Small
> --
> Posted via
> >

Can't you simply group them then use the sum rails Enumerable method?

New video up now at real fastcgi rails
deploy process! Check it out now!
Ced56202e9039027cfc2da2f70457977?d=identicon&s=25 E. Litwin (Guest)
on 2009-05-19 19:12
(Received via mailing list)
Have you looked at the group_by method of Enumerable?

"Collect an enumerable into sets, grouped by the result of a block.
Useful, for example, for grouping records by date."

On May 19, 6:57 am, John Small <>
This topic is locked and can not be replied to.