我试图打开一个docx文件并使用rubyzip 1.0.0和rails 3写回来.
在我的gemfile中我有:
gem 'rubyzip'
Run Code Online (Sandbox Code Playgroud)
我正在运行的代码是;
module Look
class Generator
def initialize(item)
doc = Nokogiri::XML.parse(item.to_xml)
xslt = Nokogiri::XSLT(File.read("<path_to_xslt_file>.xslt"))
@outxml=xslt.transform(doc)
zip = Zip::ZipFile.open("<path_to_docx_file>.docx")
@outxml
end
end
end
Run Code Online (Sandbox Code Playgroud)
虽然正确创建了@outxml(我可以手动将其添加到docx文件并查看结果),但我甚至无法开始创建zip文件,因为这...
uninitialized constant Zip::ZipFile
Run Code Online (Sandbox Code Playgroud)
检查了所有文档并尝试了很多组合后,我仍然感到非常难过.
任何人都可以告诉我为什么这不起作用?
谢谢.