【发布时间】:2015-08-14 19:39:27
【问题描述】:
我正在使用回形针上传用户头像。 这是用户模型:
has_attached_file :avatar, :styles => { :medium => "300x300>", :thumb => "100x100>" }, :default_url => "user.png", :path => "app/assets/images/:class/:attachment/:id/:basename_:style.:extension", :url => ":class/:attachment/:id/:basename_:style.:extension"
所以图像保存在 app/assets/images/user/avatar/:id/:basename_:style.:extension
但是当我这样做时
<%= image_tag @user.avatar.url %>
显示为:
<img src="/images/users/avatars/15/99e88dc27c19d8c6163d9cd305f738be_original.jpg" alt="99e88dc27c19d8c6163d9cd305f738be original">
即插入“/images”而不是“/assets”
我仔细检查了,头像图片存在于assets/images/user/avatar/文件夹中
尽管页面中的所有其他图像都使用资产管道正确显示“/assets/logo-thebighashgohere.png”
注意: 如果我手动将图像 url 作为字符串插入,这将正常工作 即:
<%= image_tag "users/avatars/15/99e88dc27c19d8c6163d9cd305f738be_original.jpg" %>
正确显示为
<img src="/assets/users/avatars/15/99e88dc27c19d8c6163d9cd305f738be_original-thebighashgohere.jpg" alt="99e88dc27c19d8c6163d9cd305f738be original thebighashgohere">
【问题讨论】:
标签: ruby-on-rails paperclip asset-pipeline