Rails - Errno :: EACCES (Permission denied) when loading an avatar for a user

I have:

  • Heroku
  • rails 3
  • carrierwave

It works fine in a local downloadable application. But he does not work on the hero. My magazines:

Completed 500 Internal Server Error in 13ms Errno::EACCES (Permission denied - /app/public/uploads/tmp): app/controllers/users_controller.rb:73:in `update' cache: [POST /users/2] invalidate, pass 

My line 73:

 if @user.update_attributes(params[:user]) 

I tried to make this local computer and click on the hero and failed

What else can I do?

+1
source share
2 answers

You cannot store files on Heroku servers, so downloading and trying to save files to the local file system will not work.

Instead, you should probably upload files to S3. Heroku documentation and CarrierWave documentation have information on setting up CarrierWave to upload files to S3 through fog. Check the documentation, get an S3 account, and upload your files there.

+2
source

When you click on Heroku, your application will compile into a pool that runs on a read-only file system, so you cannot write to it at all (i.e. you cannot write to your own public application). To make Carrierwave work on Heroku , you must set cache_dir in your Uploader class. Take a look at this answer , and especially the comment that says: “These two lines fixed it”:

 config.root = Rails.root.join('tmp') config.cache_dir = 'carrierwave' 
0
source

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


All Articles