ActiveStorage for file uploads and attachments

13998
0

ActiveStorage handles file uploads with cloud storage integration. It supports local disk, S3, Google Cloud Storage, Azure. Files attach to models via has_one_attached and has_many_attached. I use ActiveStorage for avatars, documents, images. Image variants create on-demand thumbnails—crop, resize, format conversion. Direct uploads send files straight to cloud storage, reducing server load. Previews generate thumbnails for videos and PDFs. ActiveStorage integrates with Active Job for async processing. Testing uses fixture files and attachment stubs. Understanding blob storage vs. attachments vs. variants is key. ActiveStorage simplifies file handling compared to CarrierWave/Paperclip.