Active Storage provides file uploads for Rails applications and is the storage mechanism for Action Text, Action Mailbox, and more.
Active Storage is installed by default in Jumpstart Pro.
Check out the GoRails screencast episodes on Active Storage and the Active Storage Rails Guide for more information on how to use Active Storage.
For production, we strongly recommend using a CDN for serving files. Active Storage processes images through Rails which can add unncessary load to your Rails application and slow down your app if you don't have a CDN in production.
Add direct_upload: true
to a file_field
to enable direct uploads with ActiveStorage.
<%= form.file_field :attachments, multiple: true, direct_upload: true %>
The Trix editor is also preconfigured to use direct uploads when uploading attachments.
Users have default avatars using Gravatar, but they may override this by uploading their own avatar. These avatars are uploaded and processed using Active Storage.
Sometimes a user might upload a file but close the tab leaving an orphaned file in storage. To clean these up, we need to run a cron job regularly to purge any unattached blobs from ActiveStorage.
Jumpstart Pro comes with a Rake task you can run nightly to purge any orphaned, unattached blobs. Simply add this to cron or as a scheduled job:
rails active_storage:cleanup