ActiveStorage allows you to upload files in your Ruby on Rails apps

Written by Chris Oliver
Updated over a week ago
If you handle file uploads using direct uploads, you're already good to go.

You can also upload files directly to your server. This works only if you have a single web server though. Depending on your file upload utility, make sure that your public upload folder is not tracked in git. Every release symlinks your uploads folder to a shared directory so that your files continue to be accessible after every deploy. Common folders that are automatically symlinked:
  • public/uploads
  • /storage
If you do have these folders tracked in git, make sure to remove them and redeploy your application after pushing the changes up to git.

If you have multiple web servers in your cluster, make sure to use a shared storage location like Amazon S3, DigitalOcean Spaces, or some other location. This way your files will always be accessible when they are requested. If you stored them on disk, your file might be saved to one web server, but the load balancer might send the request for the file to another web server, resulting in a 404. That's why you'll need a shared storage location as you scale up.

Was this article helpful?