【发布时间】:2017-03-22 18:14:36
【问题描述】:
我已经使用代码上传了一个文件 images.jpeg
<%= s.file_field :job_offer %> 。上传很好,但是当尝试使用代码link_to "View" , @job.job_offer.url 查看上传的文件时,它会抛出错误。日志文件中没有任何内容。此外,所有其他具有相同类型代码的地方都可以正常工作。
当我检查网络错误时,它显示Failed to load resource: the server responded with a status of 500 (Internal Server Error)。在响应头中,类型为Content-Type:text/html。如果这将是问题,如何解决这个问题?
我试过在链接中给出 type = 'image/jpeg' ,但还是一样。有没有其他方法可以输入类型?
模型.rb
has_attached_file :job_offer,
:url => "/uploads/:class/:id/:attachment/:attachment_fullname?:timestamp",
:path => "uploads/:class/:attachment/:id_partition/:style/:basename.:extension"
在架构中,
t.string "job_offer_file_name"
t.string "job_offer_content_type"
t.integer "job_offer_file_size"
【问题讨论】:
标签: ruby-on-rails ruby paperclip