Joe Morano
Joe Morano

Reputation: 1895

Paperclip: Permission denied error

Paperclip works fine on localhost, but on my deployed app, it returns the following error when I try to update an avatar:

Errno::EACCES in UsersController#update
Permission denied - /rails_apps/website/releases/20150807211111/public/system/users/avatars/000/000/562

This is the line in my Users Controller that is getting singled out:

if @user.update_attributes(user_params)

This is in my User Model:

has_attached_file :avatar, :styles => { :full => "400x720" }, :processors => [:cropper]
validates_attachment_content_type :avatar, :content_type => /\Aimage\/.*\Z/

My server uses Ubuntu 10.04.4 LTS.

What does this error mean and how can I fix it?

Upvotes: 1

Views: 2025

Answers (4)

Karl Wilbur
Karl Wilbur

Reputation: 6207

You need to add writability to not just to the ..../public folder but specifically to subfolders under ..../avatars/. So do this:

chmod -R a+w /rails_apps/website/releases/20150807211111/public/system/users/avatars

This is generally considered bad practice though. You should rather change owner or group of the folder to that of the user running the web server. Then make sure that this user/group can write to that folder.

Something like:

 chown -R www-data:www-data /rails_apps/website/releases/

Your needs may vary though.

Using Capistrano for deployment helps to completely automate the needed changes upon code deployment.

Upvotes: 0

Sohair Ahmad
Sohair Ahmad

Reputation: 457

I faced the same problem long time ago and the following works for me;

chmod 755 /rails_apps/website/releases/20150807211111/public

if you have your own machine:

chmod 777 /rails_apps/website/releases/20150807211111/public

Upvotes: -1

Helder Pereira
Helder Pereira

Reputation: 5756

This seems to be a problem with file permissions and not with Ruby on Rails. Try to run the following command in a Terminal logged in with the user that runs the web server:

chmod -R +w /rails_apps/website/releases/20150807211111/public

Upvotes: 2

user4776684
user4776684

Reputation:

It is about your folder and file permissions on your deployment machine and not about rails.

Upvotes: 0

Related Questions