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

sandwind · July 15, 2015 · Last by sandwind replied at July 15, 2015 · 1607 hits

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 谢谢大神指点

You need to Sign in before reply, if you don't have an account, please Sign up first.