的代码我使用:无法读取与由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