简体   繁体   English

Ruby On Rails image_tag()问题

[英]Ruby On Rails image_tag( ) Issue

Quick question for the RoR experts out there. RoR专家的快速提问。

I'm having a problem with getting the image_tag( ) method to properly format my HTML img element. 我在获取image_tag()方法以正确格式化HTML img元素时遇到问题。

I'm pretty certain the reason my image will not load is because of the "/images/" directory that is being added to the front of the URL. 我可以确定我的图像无法加载的原因是因为URL前面已添加了“ / images /”目录。 (SEE BELOW) (见下文)


I'm calling the image_tag( ) method like this :: 我像这样调用image_tag()方法: 在此处输入图片说明


I'm consuming MY method like this :: 我正在使用这样的MY方法:

在此处输入图片说明


This is the HTML tag that's getting generated :: 这是正在生成的HTML标记:: 在此处输入图片说明


Anyone know why this /images/ directory is getting placed on the front of my URL? 有人知道为什么这个/ images /目录放在我的URL的前面吗?

Thanks! 谢谢!

Try changing https:/secure.gravatar.com... to https://secure.gravatar.com ... 尝试将https:/secure.gravatar.com ...更改为https://secure.gravatar.com ...

Notice you have only one '/' 请注意,您只有一个'/'

You have a syntax error in your URL. 您的URL中有语法错误。

An example: If in my controller I use the following: 一个示例:如果在我的控制器中,我使用以下命令:

@my_image_url = "https:/localhost/desktop/02.png"

When I look at the generated page I get: 当我查看生成的页面时,我得到:

<img src="/images/https:/localhost/desktop/02.png" alt="bob">

If in my controller I use the following: 如果在我的控制器中使用以下命令:

@my_image_url = "https://localhost/desktop/02.png"

When I look at the generated page I get: 当我查看生成的页面时,我得到:

<img src="https://localhost/desktop/02.png" alt="bob">

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

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