When I've run into this in the past, it's generally because the Rails application was started by a user or process that is not a part of the www-data
group, and is not the www-data
user. I'd first check to confirm that the www-data
is in fact running your app.
This can be done using ps awwwx
and perhaps some grep
logic to find your app in the process stack.
I might suggest that you change the directory permissions to allow any member of the www-data
group to write to the directory as well.