环境:
ruby 1.9.2 + rails 3.0.6 + ubuntu 11.04 + centos 5.5
最近一个项目 在本地导出 excel 都没有问题 ,可是上了服务器 导出全部是 空 0 bytes , 原来是因为我部署在nginx 上 ,rails project 需要 配置使用 nginx的send-file 功能 ,
修改production.rb:
# For nginx:
config.action_dispatch.x_sendfile_header = ‘X-Accel-Redirect’
prodcution.rb 中默认的 send_file 配置使用的是apache ,lighttpd 的 配置 , 即 X-Sendfile , nginx的话, 需要使用上面配置
这样导出就没有问题了!!
SEE:
http://stackoverflow.com/questions/3724853/rails-sends-0-byte-files-using-send-file
Trackbacks
Use the following link to trackback from your own site:
http://wxianfeng.com/trackbacks?article_id=203