Topic: strange lighttpd problem /w acts_as_attachment

Not sure if this is the correct forum but I'll try and hope somebody has seen this before.

I'm using acts_as_attachment to upload and download files.  Works great on webrick but as soon as I deploy in lighttpd I get an error that the file isn't found.

The rails error looks like this:

Parameters: {"path"=>["", "var", "www", "sift", "files", "download", "0", "59217-411.pdf"]}

Basically the first param "" should be "/" and I'm not sure why it's not getting passed.

My routes.rb has this additional line:

#To make acts as attachment work, we need this line:
  map.files 'files/*path', :controller => 'bids', :action => 'download'

and my download controller looks like this:

  def download
    path = params[:path].join('/').reverse.chomp('/').reverse

The URL I get when I click to download is along the lines of:

If I *manually* add a / before var I get the file download prompt no problem, but if I instead change my routes.rb to add an extra slash:

#To make acts as attachment work, we need this line:
  map.files 'files//*path', :controller => 'bids', :action => 'download'

The URL changes to: localhost///var/www/sift/files/download/0/59217-411.pdf,
but I still have to *manually* put in an extra '/' to get the file.

Anyone have an idea?  I go the download controller and code from: … -directory

Last edited by viniosity (2007-01-23 10:10:03)

Re: strange lighttpd problem /w acts_as_attachment

Ok, I solved this -- I needed to brute force it by adding a forward / to the view.  My path statement went from:

:path => page.public_filename


:path => '/' + page.public_filename

Re: strange lighttpd problem /w acts_as_attachment

Thanks for posting your solution - I'm sure you won't be the last to face this problem.