问题描述
我正在使用 rubyzip 压缩 csv 文件,以便用户可以下载它.这在开发模式下非常有效.但是当我尝试在生产服务器(机架空间)上压缩文件时,我收到错误:LoadError(无法加载此类文件 - zip/zip).是路径问题吗?有人知道修复吗?
I'm using rubyzip to zip a csv file so uses can download it. This works perfectly in development mode. But when I tried zipping the file on the production server (rackspace) I received the error: LoadError (cannot load such file -- zip/zip). Is it a path issue? Anyone know a fix?
我的代码在这一行调用了错误:require 'zip/zip'
The error is being called in my code on this line: require 'zip/zip'
我已经尝试过这里的解决方案,但没有帮助.
I've tried the solution from here, but it didn't help.
推荐答案
我遇到了同样的问题:在require 'zip/zip'"代码上抛出错误,以及来自 这篇文章也没有帮助.
I had the same problem: error thrown on "require 'zip/zip'" code, and the solution from this post also did not help.
经过长时间的研究,我发现问题在于我的require 'zip/zip'"语句是在单独的文件中完成的
After a long research I found that the problem was that my "require 'zip/zip'" statement was done in a separate
lib/exporters/package_exporter.rb
文件,并且由于某种原因,默认情况下不会在生产中的lib"文件夹中处理require"语句.
file, and for some reason "require" statements are not handled in "lib" folder in production by default.
当我将require 'zip/zip'"移到我的开头时
When I moved "require 'zip/zip'" to the beginning of my
app/controllers/packages_controller.rb
问题解决了!
这篇关于rails 3 - LoadError(无法加载此类文件 - zip/zip)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!