I have a rails 5.2.2 app and I upgraded to 6.1.3.2. I've managed to get everything working except for ActiveStorage. The problem I am experiencing is my previously saved images on s3 now 404 with the same code. When I upgraded, rails created the following migrations (also ran bin/rails app:upgrade):
# This migration comes from active_storage (originally 20190112182829)
class AddServiceNameToActiveStorageBlobs < ActiveRecord::Migration[6.0]
def up
unless column_exists?(:active_storage_blobs, :service_name)
add_column :active_storage_blobs, :service_name, :string
if configured_service = ActiveStorage::Blob.service.name
ActiveStorage::Blob.unscoped.update_all(service_name: configured_service)
end
change_column :active_storage_blobs, :service_name, :string, null: false
end
end
def down
remove_column :active_storage_blobs, :service_name
end
end
and
# This migration comes from active_storage (originally 20191206030411)
class CreateActiveStorageVariantRecords < ActiveRecord::Migration[6.0]
def change
create_table :active_storage_variant_records do |t|
t.belongs_to :blob, null: false, index: false
t.string :variation_digest, null: false
t.index %i[ blob_id variation_digest ], name: "index_active_storage_variant_records_uniqueness", unique: true
t.foreign_key :active_storage_blobs, column: :blob_id
end
end
end
I'm using this code to render the image:
<%= image_tag(a.file.variant(resize: "100x100"), class: 'p-1') if a.file.variable? %>
Any new image I upload through ActiveStorage works and is displayed via the image_tag. However, any file I had previously stored via ActiveStorage 404s.
In development.rb I am also setting config.active_storage.service = :amazon. This configuration hasn't changed since the upgrade.