Error in send_file

I’m trying to add a link to download a zip file. I created a
controller method that makes the call to send_file:

def getzip
send_file ‘file.zip’
end

When I navigate to this link I get a MissingFile exception. The file
definitely exists (and U triple-checked paths and spelling) and the
permissions are 644. I tried moving it to the /public folder and
updating the getzip method to grab it from here, but I still get the
same exception. Is there any configuration with rails or apache I can
check? I have used send_data in other modules without any problems,
so I’m scratching my head on this one.

Thanks.

Mike

On 17 Dec 2007, at 03:24, Mike wrote:

I’m trying to add a link to download a zip file. I created a
controller method that makes the call to send_file:

def getzip
send_file ‘file.zip’
end

A path like that will be relative to your current working directory
(usually the same as you rails_root). Try using an absolute path/not
relying on the current working directory (ie /foo/bar/file.zip or
RAILS_ROOT + ‘/file/zip’.
File.expand_path ‘file.zip’ should tell you exactly what path it’s
trying to access.

Fred

Thanks! Using expand_path ‘file.zip’ showed it was looking for it in /
public. I suspected it was looking there, but I was using ‘/public/
code.zip’ instead of just the filename.

Mike

On Dec 16, 11:08 pm, Frederick C. [email protected]