The problem is not with Rails but with Nginx which is pretty evident from the nginx error.log
. This question helped me understand what I was dealing with - Rails 3 + carrierwave + nginx = permission denied.
Nginx uses the client_body_temp_path
directive to specify the location where it will temporarily store the uploaded files from the user request. Homebrew had set it by default to /usr/local/var/run/nginx
. This folder also contains fastcgi_temp
, proxy_temp
, scgi_temp
and uwsgi_temp
for me. Nginx worker processes run with user nobody
and they were not able to access these folders. I chowned all these folders to the nobody
user, but that did not help.
Finally, I did
client_body_temp_path /tmp/nginx/;
inside the HTTP module of my nginx.conf
to make it work.
Doing a ls -l
shows
drwx------ 2 nobody wheel 68 Feb 1 14:44 nginx
I am not sure why this worked inside /tmp
and not inside the original /var/run/nginx
. I belive I will face similar issue when I use other temp folders or in production. Will update this thread if and when that happens.
I recommend symlinking the other relevant logs like the nginx access and error log, pow access and app log to the /log
directory of your Rails app. It helps in looking up errors in one of these when you face a tricky bug.