我正在使用回形針將文件(PDF和Word文檔)上傳到我的Rails應用。到目前爲止,一切似乎都奏效。然而,當我點擊鏈接進行查看我的pdf文件(<%= link_to "My document", @pin.document.url, target: "_blank" %>
)一個新的水龍頭開着,我得到一個路由錯誤:No route matches [GET] "/documents/original/missing.png"
路由錯誤沒有路由匹配[GET]「/documents/original/missing.png」
我應該包括在我的route.rb文件的新路徑?
Rails.application.routes.draw do
resources :pins
devise_for :users
root "pins#index"
get 'about' => 'pages#about'
針型號:
class Pin < ActiveRecord::Base
has_attached_file :document
validates_attachment :document, :content_type => { :content_type => %w(application/pdf application/msword application/vnd.openxmlformats-officedocument.wordprocessingml.document) }
end
@Nishu謝謝。看看類似的答案,但我很難將其應用於我的問題。你知道我是否需要改變視圖中的內容或添加新路線嗎? '<%= link_to「我的文檔」,@ pin.document.url,target:「_blank」%>' – Cyzanfar
它看起來像這個pin沒有附加文檔,但在顯示之前不檢查它鏈接到它。 –
我該如何解決這個問題? – Cyzanfar