File upload does not work with Rails 4 in development using Pow and Nginx

I use Pow and Nginx to service my Rails 4 application in development. A simple file download returns 500 errors, and the request does not reach the Rails controller. I assume this is because the request is not mentioned in the Rails log. Without mentioning the error, I'm not sure what is going wrong here.

I started by loading the Ajax file, but replaced it with a simple form that also doesn't work.

Tried this

Original Upload Button

and then moved on to this

Simple upload form

Current avatar .html.erb

<%= form_for @user, html: { multipart: true }, method: "post", url: '/settings/avatar/update', class: "", id: "update_avatar" do |f| %>
  <%= f.file_field :avatar, class: 'js-upload-photo-button js-change-avatar-btn', accept: 'image/png,image/gif,image/jpeg,image/jpg' %>
    <%= f.submit "Upload" %>
<% end %>

Chrome request headers

Full request headers

extended request header section

Expanded Request Headers section

nginx.log

127.0.0.1 - - [01/Feb/2014:11:28:26 +0530] "POST /settings/avatar/update HTTP/1.1" 500 643 "https://allotrop.dev/settings/avatar" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_8_4) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/32.0.1700.77 Safari/537.36"

pow access.log

[Sat Feb 01 2014 11:28:26 GMT+0530 (IST)] INFO [127.0.0.1] GET allotrop.dev /500.html

, Rails 500 rails 500 , Rails 3.2.13, 500 500 (Rails, Passenger, Nginx, Postgres)

, , , . , - .

1

.rb

post '/settings/avatar/update', to: 'settings#update_avatar'

2

nginx. BTW, Homebrew, /usr/local/Cellar/nginx/1.4.0/logs/error.log

Nginx/error.log

2014/02/01 13:05:54 [crit] 8787#0: *85813 open() "/usr/local/var/run/nginx/client_body_temp/0000000010" failed (13: Permission denied), client: 127.0.0.1, server: *.dev, request: "POST /settings/avatar/update HTTP/1.1", host: "allotrop.dev", referrer: "https://allotrop.dev/settings/avatar"

+4
1

Rails, Nginx, nginx error.log. , - Rails 3 + carrierwave + nginx = .

Nginx client_body_temp_path, , . Homebrew /usr/local/var/run/nginx. fastcgi_temp, proxy_temp, scgi_temp uwsgi_temp . Nginx nobody, . nobody, .

,

client_body_temp_path /tmp/nginx/; HTTP nginx.conf, .

ls -l

drwx------ 2 nobody wheel 68 Feb 1 14:44 nginx

, /tmp, /var/run/nginx. , , . , .

, nginx , /log Rails. , .

+20

Source: https://habr.com/ru/post/1524811/


All Articles