【发布时间】:2016-11-02 19:06:52
【问题描述】:
我从 Google Drive API 返回了以下哈希:
@export_links=
{"application/rtf"=>
"https://docs.google.com/feeds/download/documents/export/Export?id=xxx&exportFormat=rtf",
"application/vnd.oasis.opendocument.text"=>
"https://docs.google.com/feeds/download/documents/export/Export?id=xxx&exportFormat=odt",
"text/html"=>
"https://docs.google.com/feeds/download/documents/export/Export?id=xxx&exportFormat=html",
"application/pdf"=>
"https://docs.google.com/feeds/download/documents/export/Export?id=xxx&exportFormat=pdf",
"application/zip"=>
"https://docs.google.com/feeds/download/documents/export/Export?id=xxx&exportFormat=zip",
"application/vnd.openxmlformats-officedocument.wordprocessingml.document"=>
"https://docs.google.com/feeds/download/documents/export/Export?id=xxxx&exportFormat=docx",
"text/plain"=>
"https://docs.google.com/feeds/download/documents/export/Export?id=xxx&exportFormat=txt"},
我可以像这样记录导出链接:
logger.debug file.export_links
但是,我无法获取文本/纯 url,尝试:
logger.debug file.export_links["text/plain"]
undefined method[]' for nil:NilClass` 出错。
如何在 @export_links 中获取 text/plain 的值?
【问题讨论】:
-
file.export_links.class是什么? -
@spickermann 返回 Hash 或 NilClass
标签: ruby-on-rails arrays ruby hash