[英]Image from URL attached to image_tag won't display in ruby on rails
我正在從對象中取回數據,目的是在視圖中顯示圖像。 我正在將對象調試到瀏覽器中,這就是我看到的內容:
image: !ruby/object:Parse::File
parse_filename: xxxxxxxx-xxxxxxxxx-xxxxxxxxxx-image.jpg
url: http://files.parse.com/xxxxxxxx-xxxxxxxxx-xxxxxxxxxx-image.jpg
在我看來,我嘗試了以下方法:
<%= image_tag object["url"] %>
<%= image_tag object["parse_filename"] %>
但是,該圖像從未顯示。
已用Google搜索,但找不到其他有關如何進行此操作的信息。 據我所知這應該,但事實並非如此。
希望能有所幫助
謝謝你的時間
更新完整的調試結果:
--- !ruby/hash:Parse::Object
alternativeColour: false
collection: 1
colour: 2
favourite: false
gender: 2
image: !ruby/object:Parse::File
parse_filename: sds232-eee7-4203-840b-jk233k23232-image3.jpg
url: http://files.parse.com/sdsd232-7f16-sd23-sds2-a4c7884d118e/dcefd915-eee7-4203-840b-jk233k23232-image3.jpg
price: 23.42
productType: 2
recommended: false
size: 6
title: Bomber Jacket
createdAt: '2014-04-03T20:33:41.020Z'
updatedAt: '2014-06-18T19:03:24.220Z'
objectId: yZksdhNJPm
似乎您沒有使用正確的對象或屬性。
首先,嘗試使用如下網址打印圖像:
<%= image_tag "http://files.parse.com/xxxxxxxx-xxxxxxxxx-xxxxxxxxxx-image.jpg" %>
一旦可行,請嘗試獲取正確的對象和屬性。 下一行應提供所有對象詳細信息
<%= debug object %>
如果什么都不打印,請檢查您的控制器變量以及如何在視圖上使用它們
更新:
根據完整的對象調試消息,該屬性應作為object["image"].url
來訪問
我必須使用object [“ image”]。url進行訪問。 我想知道為什么url和file_pathname在圖像下略有縮進。 現在我知道為什么了。
image["image"].url
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.