Ruby 1.9.3 Rails 3.2.11. I need to require the ails zip library but can’t figure out how to do it. Here is my code which I need only in a single action in a controller.
file_name = "natfiles.zip"
t = Tempfile.new("temp_natfiles")
Zip::ZipOutputStream.open(t.path) do |z|
z.put_next_entry('NAT00010')
z.print IO.read("tmp/nat00010")
end
send_file t.path, :type => 'application/zip',
:disposition => 'attachment',
:filename => file_name
t.close
In your Gemfile, add a line
Then run
bundle install. It will be available everywhere.