Ruby On Rails image_tag()问题

时间:2015-02-01 00:40:18

标签: ruby-on-rails ruby

RoR专家的快速提问。

我遇到了使用image_tag()方法正确格式化HTML img 元素的问题。

我很确定我的图片无法加载的原因是因为“/ images /”目录被添加到URL的前面。 (见下文)


我正在调用image :: tag()方法,如:: enter image description here


我正在使用这样的方法::

enter image description here


这是生成的HTML标记:: enter image description here


有人知道为什么这个 / images / 目录会放在我的网址前面吗?

谢谢!

2 个答案:

答案 0 :(得分:2)

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

请注意,您只有一个' /'

答案 1 :(得分:1)

您的网址中存在语法错误。

一个例子: 如果在我的控制器中,我使用以下内容:

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

当我查看生成的页面时,我得到:

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

如果在我的控制器中,我使用以下内容:

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

当我查看生成的页面时,我得到:

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