Can't upload files when WEBrick running in daemon mode

Hi,
When running my app in development with WEBrick in daemon mode I get the
following error when trying to upload a file:

Errno::ENOENT in UploadController#create

No such file or directory - public/data/upload/google

|Rails.root: /home/resource_portal/website|

Application Trace http://localhost:3000/upload# | Framework Trace
http://localhost:3000/upload# | Full Trace
http://localhost:3000/upload#

|app/models/upload.rb:29:in initialize' app/models/upload.rb:29:in open’
app/models/upload.rb:29:in filesave' app/controllers/upload_controller.rb:16:in create’
rake-0.8.7/ruby/1.9.1/gems/actionpack-3.0.3/lib/action_controller/metal/implicit_render.rb:4:in
send_action' rake-0.8.7/ruby/1.9.1/gems/actionpack-3.0.3/lib/abstract_controller/base.rb:151:in process_action’|

I do not get this error when not running in daemon mode. I’ve googled a
bit but can’t find a reason. Does anyone have any ideas?

Also the reason I want to run in Daemon mode is because I have to host
my app on a uni virtual machine, and start the server after logging in
with ssh. When I close the ssh connection the server (if not running in
background) also seems to get killed.

Any ideas as to how I may be able to work around this?

Thanks,
Jen.

On Sun, Jul 3, 2011 at 6:19 AM, Jen [email protected] wrote:

When running my app in development with WEBrick in daemon mode I get the
following error when trying to upload a file:

Errno::ENOENT in UploadController#create

No such file or directory - public/data/upload/google

I do not get this error when not running in daemon mode. I’ve googled a bit
but can’t find a reason. Does anyone have any ideas?

My guess would be that ‘current working directory’ doesn’t mean the
same thing to a daemonized process; how are you specifying the target
directory? Regardless…

Also the reason I want to run in Daemon mode is …

Why Webrick? It’s only intended for desktop development work; you
would be better off using e.g. unicorn (my preference) or passenger
in a production environment.

Alternatively, if those aren’t an option, see if you have screen on
the
system you’re using (Screen - GNU Project - Free Software Foundation).

HTH,

Hassan S. ------------------------ [email protected]

twitter: @hassan

I personally use mongrels for my development chops, and passenger in
production environments; I have yet to take the unicorn for a ride. I
advise
you to drop WEBrick entirely. Also, be sure to look at this security
considerations
http://guides.rubyonrails.org/security.html#file-uploads if
you haven’t yet done so. Security always bears reminding…

[]s,
Paulo Muggler

On Sun, Jul 3, 2011 at 11:53, Hassan S.

Hi,
I solved this by including the absolute path to the directory where the
uploaded files are placed. Now the code is:

 #takes the upload object and extracts the file.

def filesave
#Calls the .original_filename method on the upload object and stores in
the variable name
name = upload.original_filename
directory = “/home/resource_portal/website/public/data/upload”

This works with WEBrick, but am now using thin.

Hope this helps anyone else experiencing the same problem.

Cheers,
Jen!