如何在数据库中存储ruport表数据对象?

发布于 2024-08-03 21:44:37 字数 592 浏览 3 评论 0 原文

我打算将每晚构建的报告数据存储在数据库中,然后在用户实时请求报告时使用格式化程序。

一些线索... 包含数据的 Ruport::Data::Table 对象是 Ruport::Data::Record 对象的集合,可通过“data”访问' 属性即

Ruport::Data::Table 对象

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

Ruport::Data::Record 对象包含需要进入数据库的 'data' 哈希

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

我正在使用 Rails 和 ActiveRecord

我怎样才能实现这个目标?

I intend to store a nightly build of report data in a DB and then use formatters when a user requests for a report in real-time.

A few clues...
The Ruport::Data::Table object - that contains the data - is a collection of Ruport::Data::Record objects, accessible via the 'data' attribute 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 which needs to go into the DB

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

I'm using Rails and ActiveRecord

How can I achieve this?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

凉栀 2024-08-10 21:44:37

您可以使用例如 to_yaml 序列化内容,或使用旧的 Marshal.#dump 和 #load。

我做了类似的事情,尽管我的(相对简单的)数据包含在 OpenStruct 中。我异步生成几个运行时间较长的报告(通常是过夜),并根据请求从“cached_reports”表中检索其内容。

You could serialize the content using, for example, to_yaml, or use the older Marshal.#dump and #load.

I do something similar, although my - relatively simple - data is contained in an OpenStruct. I generate several longer-running reports asynchronously (usually overnight) and retrieve their content from a "cached_reports" table on request.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文