11

Im attempting to open a docx file and write back into it using rubyzip 1.0.0 and rails 3.

In my gemfile I have:

gem 'rubyzip'

and the code i'm running is;

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

While the @outxml is created correctly (I can manually add it to the docx file and see the results), I can't even begin with creating the zip file because of this...

uninitialized constant Zip::ZipFile

Having checked all the documentation and tried many combinations I'm still completely stumped.

Can anyone please tell me why this won't work?

Thanks.

Simone Carletti
  • 173,507
  • 49
  • 363
  • 364
mvanio
  • 505
  • 3
  • 15
  • Just figured this one out by checking the latest documentation. Seems v1.0.0 was only released today so everything I read was out of date. Anyway, the solution is to use Zip::File.open. – mvanio Aug 29 '13 at 19:22
  • You might want to make that comment an actual answer and then choose it as the correct answer so people in the future can find it easily. – Mario Zigliotto Aug 29 '13 at 20:41
  • Yes. SO wouldn't let me add this as an answer until 8 hours had passed. – mvanio Aug 30 '13 at 17:47

1 Answers1

16

Just figured this one out by checking the latest documentation. Seems v1.0.0 was only released today so everything I read was out of date.

Anyway, the solution is to use

Zip::File.open
mvanio
  • 505
  • 3
  • 15