How to store the data object of the ruport table in the database?

I intend to store the nightly collection of report data in the DB and then use the formatting when the user requests the report in real time.

A few hints ... The Ruport :: Data :: Table object containing data is a collection of Ruport :: Data :: Record objects accessible via data ', i.e.

Ruport :: Data :: Table Object

=> Ruport :: Data :: Table: 0xb6455680 @column_names = [], @ record_class = "Ruport :: Data :: Record", @data = []

The Ruport :: Data :: Record object contains the 'data' hash that should go into the DB

Ruport :: Data :: Record: 0x7ff138104c90 @data = {}, @attributes = []

I am using Rails and ActiveRecord

How can I achieve this?

+2


source to share


1 answer


You can serialize content using for example to_yaml

, or use older Marshal . # dump and #load.



I am doing something similar, although mine - relatively simple - data is contained in OpenStruct. I am generating several longer reports asynchronously (usually overnight) and retrieving their content from the "cached_reports" table upon request.

+1


source







All Articles