hey so I’m trying to zip all the files contained in a directory
(RubyZip). heres what I have:
def bundle
#create the ZIPfile with the title of (:id).zip
bundle_filename = "public/attachments/#{self.id}/#{self.id}.zip"
#open the ZIPfile in order to add items in
Zip::ZipFile.open(bundle_filename, Zip::ZipFile::CREATE) {
|zipfile|
Dir.foreach("public/attachments/#{self.id}") do |item|
t = File.open(item)
zipfile.add(t, "public/attachments/#{self.id}")
end
}
#change permissions on ZIPfile
File.chmod(0644, bundle_filename)
self.save
end
This successfully executes the first line and creates the zip file with
the correct name but it is not adding to the zip file all the files
contained in that directory. Any Ideas?