While having trouble getting Unix zip to play nice with Ruby's Tempfile I found that it was much easier to just avoid a temp file altogether by using a pipe create with IO.popen. Example code below shows how you might zip up a directory and send it back to the user from a controller: