【发布时间】:2012-10-02 02:44:48
【问题描述】:
我一直在多个模型中将 Paperclip 与我的应用程序一起使用,但以下问题给我带来了问题:
在模型中:
has_attached_file :image, :path => (Rails.root + "document_libraries/:id/filename").to_s,
:url => "/document_libraries/:id"
在视图中:
<%= image_tag(@document_library.image.url) if @document_library.image? %>
这会在浏览器中显示“丢失的图像”图形。我在这里做错了什么?我的公共目录中没有图像。我有这个代码的不同模型,它完美地工作:
has_attached_file :file, :path => (Rails.root + "team_photos/:id/:filename").to_s,
:url => "/team_photos/:id"
image_tag(@team_photo.file.url)
我已检查 document_libraries 文件夹是否存在于 rails 根目录中,并且我正在使用的特定记录存在实际的 jpg。权限与 team_photo 模型相同,可以正常工作。
【问题讨论】: