在 Ruby 1.9.2 中导出为 CSV

发布于 2024-10-31 15:29:50 字数 703 浏览 3 评论 0原文

使用逗号进行 CSV 导出的现有应用程序已升级到 Ruby 1.9.2 现在没有任何导出。基本上,服务器只是坐着旋转。我知道逗号有 FasterCSV 依赖性,但 FasterCSV 在 1.9.2 中不再受支持,因为 CSV 位于核心中。

根据文档,即使没有 FasterCSV,逗号也应该起作用,但我没有这种经验。我无法使用此代码导出任何内容:

控制器:

format.csv do
    @sis_action_rendered = true
    render :csv => current_user.authorized_clinical_stuff
  end

模型:

comma do # implicitly named :default
user :salutation
name
email
user :login
user :ethnicity
user :gender
user :is_verified => 'APTA Trained'
work_phone
alternate_phone
site_names
site_address
degree
pt_degree
ci_credentialed?
ci_advanced_credentialed?
board_certs
updated_at
end

请记住,模型代码正在从多个相关对象中提取信息以生成一个 CSV。

An existing app, using comma for CSV exports was upgraded to Ruby 1.9.2 And now nothing exports. Basically, the server just sits and spins. I know there is a FasterCSV dependency for comma, but FasterCSV is no longer supported in 1.9.2 as CSV is in the core.

According to the documentation, comma should work even without FasterCSV, but I am not having that experience. I can't get anything to export using this code:

CONTROLLER:

format.csv do
    @sis_action_rendered = true
    render :csv => current_user.authorized_clinical_stuff
  end

MODEL:

comma do # implicitly named :default
user :salutation
name
email
user :login
user :ethnicity
user :gender
user :is_verified => 'APTA Trained'
work_phone
alternate_phone
site_names
site_address
degree
pt_degree
ci_credentialed?
ci_advanced_credentialed?
board_certs
updated_at
end

Keep in mind that the model code is pulling info fro several related objects to generate one CSV.

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

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

发布评论

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

评论(1

如果没结果 2024-11-07 15:29:50

FasterCSV 是 1.9.2 中的 CSV。

来自文档

此版本的 CSV 库最初名为 FasterCSV。 FasterCSV 旨在替代 Ruby 当时的标准 CSV 库。

[...]

我们一定已经实现了我们的目标,因为 FasterCSV 已重命名为 CSV 并取代了原来的库。

FasterCSV IS CSV in 1.9.2.

From the docs:

This version of the CSV library began its life as FasterCSV. FasterCSV was intended as a replacement to Ruby’s then standard CSV library.

[...]

We must have met our goals because FasterCSV was renamed to CSV and replaced the original library.

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