在 Ruby 1.9.2 中导出为 CSV
使用逗号进行 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 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
FasterCSV 是 1.9.2 中的 CSV。
来自文档:
FasterCSV IS CSV in 1.9.2.
From the docs: