簡體   English   中英

查看回形針附件不起作用

[英]viewing of paperclip attachment not working

我使用代碼<%= s.file_field :job_offer %>上傳了一個文件images.jpeg。 上傳很好但是當嘗試使用代碼link_to "View" , @job.job_offer.url上傳的文件時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',但仍然是一樣的。 有沒有其他方式給類型?

model.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"

要顯示圖像,您需要使用下面的圖像標記語法:

<%= link_to root_path do %>
    <%= image_tag "image_path", class: "some css class here" %>
<% end %>

要么

<%= link_to( image_tag(@job.job_offer.url), jobs_path, :class=>"abc") %>

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM