Tag: activerecord

在Rails 3.2中调用一个数组的ActiveRecord关联方法

目标:使用与我的HTML表中的相似的3个关联模型的信息生成Excel文档。 to_xls gem需要这个数组作为列表。 https://github.com/splendeo/to_xls 期望的输出: (working for both) (working for both) (working in HTML, not in Excel) territory.branch.name territory.zip territory.mailedcounts.maximum(:maileddate) My Branch 90210 2012-05-01 My Branch 90211 2012-05-03 My Branch 90212 分行有许多地区。 一个地区有许多Mailedcounts。 我可以通过show.html.erb的内置ActiveRecord方法在我的视图中调出正确的数据 <% for territory in @territories %> <tr> <td><%= territory.branch.name %></td> <td><%= territory.zip %></td> <td><%= territory.mailedcounts.maximum(:maileddate) %></td> </tr> <% end > 这是我已经正确导出到目前为止 […]

从XML创build模型并导入到数据库

你好我是一个初学者,所以任何build议可能是真正有用的,即使不是一个技术解决scheme,但一个概念的方式来实现它,我有我需要在我的Rails应用程序中search的产品多张.xls文件。 什么是从xls文件创build模型最无泪的方法? 每张纸页有完全不同的分页,所以我需要为每个纸张页面做一个模型? 你可以在这里看到一个示例文件