简体   繁体   English

导轨image_tag不起作用

[英]rails image_tag not working

UPDATE: does anyone know why the images show up in Firefox but not in Chrome? 更新:有人知道为什么图像在Firefox中显示而不在Chrome中显示吗?

I just tested my app in Firefox and the images show up! 我刚刚在Firefox中测试了我的应用程序,并且显示了图片! But they do not show up in Google Chrome. 但是它们不会显示在Google Chrome中。 Does anyone know why this is? 有人知道为什么是这样吗?

Original question posted to Ruby-on-Rails and Ruby..below line 原始问题发布到Ruby-on-Rails和Ruby ..


Ok, so I'm having hell with the image_tag in rails. 好的,所以我在使用rails中的image_tag时遇到了麻烦。 I have the following code in my index.html.erb 我的index.html.erb中有以下代码

code in.. 输入代码

<% @most_recent_tweets.each do |tweet| %>
    <%= image_tag (tweet["user"]["profile_image_url"]) %>
<% end %>

The following is what appears on the actual webpage 以下是实际网页上显示的内容

code out.. 编码出来..

<img alt="Eli_face_1_bigger_normal" src="http://a2.twimg.com/profile_images/498988018/eli_face_1_bigger_normal.jpg">

The html for the image shows up in the code but no image displays in the browser. 图片的html显示在代码中,但浏览器中未显示图片。 Why is this? 为什么是这样? Any ideas? 有任何想法吗?

Try adding .html_safe 尝试添加.html_safe

image_tag (tweet["user"]["profile_image_url"]).html_safe image_tag(tweet [“ user”] [“ profile_image_url”])。html_safe

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM