的代碼我使用:無法讀取與由send_file功能文件中的Rails 3
鑑於文件:
<%= link_to "Download", download_image_path(image) %>
在控制器:
def download
@image = Image.find(params[:id])
send_file "#{RAILS_ROOT}/public" + @image.attachment.url
end
我得到一個錯誤:
Cannot read file /Users/mohit/projects/my_app/public/system/attachments/4/original/Screen Shot 2011-11-04 at 3.14.03 PM.png?1320582022
PS:重複檢查,文件存在。服務器上的所有相關控制器中的所有文件(圖像,pdf,視頻)都是同樣的問題。
如果使用brakeman分析代碼,那麼它會將錯誤顯示爲用作文件名的MOdel屬性。只是跑剎車。 其考慮爲 send_file Image.find(params [:id])。uploaded_file.path – errakeshpd