Rails 在使用 image_tag 上有出现的问题,求指教,求指点

sandwind · 2015年07月15日 · 最后由 sandwind 回复于 2015年07月15日 · 1608 次阅读

1.首先我实现了图片上传,上传到又拍云得到的 2.如下代码去获取图片的 url

@profile.avatar.url(:normal)

3.在 erb 模板中的 使用如下代码去使用图片显示

<%= image_tag(@profile.avatar.url(:normal),class:"232323")%>

但是出现以下很奇怪的现象 希望大神里指点迷经

这里从 html 代码上看发现前面始终要加上/images/ 导致我不能显示出图片

image_tag 会把接受的参数当内部路径处理,外域的地址可以显示的加上 http://

用 image_url 试试

<img src="<%= image_path(@profile.avatar.url(:normal)) %>" alt="" class="" />

@xworm 谢谢大神指点

需要 登录 后方可回复, 如果你还没有账号请 注册新账号