If you've been following along:
Then you're ready for one of the cool features of Active Storage: mirroring. This one is really easy to set up:
1. Ensure that you have created
2. Update your storage_services.yml file with a configuration stanza for mirroring:
mirror: service: Mirror services: [ amazon, local, google ]
3. Edit your production.rb file:
config.active_storage.service = :mirror
4. Deploy the application. You should still be able to add user avatars.
What does mirroring do? It gives you built-in redundancy against cloud service failures. In the case of the configuration above:
- Files are uploaded to Amazon and Google, and stored locally.
- Files are served from Amazon (the first member of the services array)
Should AWS go down for an entire region, you'd only need to change the services array in your config file, restart your server, and you'd be up and running again.
BUT: Note the "should" in step 4. As I write this, this doesn't actually work with the code in the Active Storage repo, because the MirrorService doesn't get configured properly. See issue 9, which includes a quick and hacky patch for the Active Storage internals to get things working.