Try ActiveStorage with S3

I tried Rails new feature ActiveStorage

Rails version is v5.2.0.beta2

Default service is Disc, and I tried S3 at this time.

  • config/storage.yml stays almost as it is.
  • Add mini_magick gem in my Gemfile to use resizing feature.
  • Add aws-sdk-s3 gem to upload to and read from S3.
  • Set config.active_storage.service = :amazon in config/environments/development.rb
  • Run bin/rails active_storage:install and a migration file copied from active_storage.
  • After running bin/rails db:migrate, active_storage_attachments and active_storage_blobs tables are created.
  • Do the same things on README, I could upload images and read the image files from S3.

It seemed to access an image through rails server first, then redirected to S3 (I don’t understand this behaviour.)

I wondered whether I can replace ActiveStorage from Carrierwave or not…

Anyway, this new feature is really helpful and I was impressed with Rails after a long time.