Question

2 views
Skip to first unread message

Joel M. Gottlieb

unread,
Mar 18, 2009, 9:28:57 AM3/18/09
to ruby-r...@googlegroups.com
Hello,
 
I have a Ruport question - I haven't found a suitable example on the Web.
 
My experience with Ruport has so far involved printing columns from tables, where the columns are already existing columns in the database representation of these particular tables.
 
Suppose I have a table that I want to present by column; and along with the columns I also want to present a summarized list of "line items".
Suppose, for example, I have a "Clothing Donation", which contains several line items - 3 shirts, 2 pairs of shoes, etc.
 
I want to report something like this:
 
Donation Date        Donor               List of Items
2009-03-18             John Doe          (3 shirts, 2 pairs of shoes, 2 pairs of socks)
 
The "line items" are not columns in the ClothingDonation table. Instead, there is a ClothingDonation table, and there is a ClothingLineItem table, and each ClothingLineItem has a ClothingDonation ID, pointing to the "parent" clothing donation table.
 
Clearly, I need to build the summarized list of line items, and then get Ruport to write it out along with the other columns of the Clothing Donation table.
 
Could someone kindly point me to an example of how this might be accomplished?
 
Thanks-
 
Joel
 

Gregory Brown

unread,
Mar 18, 2009, 9:35:32 AM3/18/09
to ruby-r...@googlegroups.com
On Wed, Mar 18, 2009 at 9:28 AM, Joel M. Gottlieb
<joel.g...@gmail.com> wrote:
> Hello,
>
> I have a Ruport question - I haven't found a suitable example on the Web.

Please do not use such terrible subject lines. Nearly everyone who
posts to this list has a 'question', and those who read it are much
more likely to answer those questions which they can determine whether
they have any experience with by subject line alone.

Just create a table manually using Table(), then build a custom
formatter which renders both tables however you'd like them.

You can see a bit about custom formatters in this article:
http://www.oreillynet.com/pub/a/ruby/2008/04/08/ruport-business-reporting-for-ruby.html?page=1

and a whole lot more in the Ruport Book.

-greg

Andrew France

unread,
Mar 18, 2009, 9:40:11 AM3/18/09
to ruby-r...@googlegroups.com
Joel M. Gottlieb wrote:
> Clearly, I need to build the summarized list of line items, and then
> get Ruport to write it out along with the other columns of the
> Clothing Donation table.
>
> Could someone kindly point me to an example of how this might be
> accomplished?

I think the standard calculated columns (add_column method) should be
what you need:
http://ruportbook.com/data_manipulations.html#tabular_column_operations_and_calculated_fields

You'd have to write the code that actually summarises the number and
type of items into a string.

Hope that helps.

Andrew

Reply all
Reply to author
Forward
0 new messages