Deploying Rails app on Heroku - Images disappears after some time

462 views Asked by At

I deployed a simple React+Rails Blog application on Heroku. I deployed separate projects for frontend and backend.

Everything in the application is working fine but the issue is that images disappeared after some time due to routing error. The same URL works for some time but then it stops working.

First I was uploading images using active_storage and faced this issue and now I am using carrierwave but the issue is still there. I tried different solutions but nothing worked.

I am facing issue only on production and not on localhost.

Heroku Logs

enter image description here

Production.rb

enter image description here

1

There are 1 answers

1
Tun On BEST ANSWER

As of 2020/10/11, Heroku documentation on ActiveStorage says

Heroku has an “ephemeral” hard drive, this means that you can write files to disk, but those files will not persist after the application is restarted

Recommendation by the same document is

Instead of storing uploaded files to disk, the best practice is to leverage a cloud file storage service such as Amazon’s S3.

AFAIR, Heorku CLI warns you of this fact. You should have noticed that.