I have recently updated Rails to 6.1 to support multiple buckets uploads in ActiveStorage. However, after upgrading, updating ActiveStorage, deleting everything and reinstalling again, it still does not work. I followed this guide. I also followed this. Here's my implementation:
# storage.yaml
amazon_contracts:
service: S3
access_key_id: <%= Rails.application.credentials.dig(:aws, :access_key_id) %>
secret_access_key: <%= Rails.application.credentials.dig(:aws, :secret_access_key) %>
region: sa-east-1
bucket: contracts-raw-ac1
amazon_templates:
service: S3
access_key_id: <%= Rails.application.credentials.dig(:aws, :access_key_id) %>
secret_access_key: <%= Rails.application.credentials.dig(:aws, :secret_access_key) %>
region: sa-east-1
bucket: templates-raw-ac1
# development.rb (default service to be used)
config.active_storage.service = :amazon_contracts
# template.rb
has_one_attached :template, service: :amazon_templates
# contract.rb
has_many_attached :contracts, service: :amazon_contracts
However, both the template
and contract
uploads go directly to the contracts bucket. I have tried removing the default service from the development.rb
, but I get cannot get name of nil Class
error. Any help is very much appreciated.