1

following the documentation for rubyzip 2.3.2, I have this method:

def zip_files(zip_file_name, files)
  Zip::File.open(zip_file_name, Zip::File::CREATE) do |zipfile|
   files.each do |filename|
    zipfile.add(filename, File.join('.', filename))
   end
  end
end

files = ["test.txt", "test2.txt"]

zip_files("testing.zip", files)

this produces an error: undefined method 'join' for Zip::File:Class (NoMethodError)

This does create a "testing.zip" file, but it is empty

the files live in the same directory and I've tested that with: puts files the files are returned

bradb
  • 11
  • 1
  • I think this is confusing `::File` with `Zip::File`. Have you done any strange `include` actions? – tadman Dec 21 '22 at 21:41
  • I'm just following the documentation (https://www.rubydoc.info/gems/rubyzip/2.3.2). I have not tried any include actions – bradb Dec 21 '22 at 21:58

1 Answers1

0

the fix was changing "File.join" to "::File.join"

bradb
  • 11
  • 1