[RUBY] Introduce Active Storage

ActiveStorage Use Active Storage to upload images. Along with this, install software called ImageMagick that can convert images and a gem called MiniMagick to use it on rails.

-ImageMagick: Image conversion tool (Gem that can process images from the command line) -MiniMagick: Gem that enables you to use the functions of ImageMagick in Ruby -Image Processing: Gem that provides the function to adjust the image size that MiniMagick cannot provide

First, install ImageMagick from Homebrew in the terminal

Install imagemagick


% brew install imagemagick

gemfile


#Described at the bottom of the Gemfile
gem 'mini_magic'
gem 'imaged_processing', '~> 1.2'

If you can add it, do bundle install. Finally, use rails c to disconnect the local server and start the server with rails s.

Now finally install Active Storage.

Terminal


% rails active_storage:install
#↑ When you execute the command, a migration file for managing images in the table will be generated, so migrate with the ↓ command.
% rails db:migrate

If active_storage_attachments and active_storage_blogs are reflected in the DB, the installation of ActiveStorage and image processing tools is successful.

Recommended Posts

Introduce Active Storage
About Active Storage
About DelegationError (Active Storage)
Active Storage Initialization Manual
[Beginner] About Active Storage
Post videos with Active Storage
Move Active Storage on S3 locally
[Rails] How to use Active Storage
Unit tests under Active Storage deployment
[Active Storage] Validation settings when uploading files
Rails Active Storage shrinks images before uploading
Post / delete multiple images with Active Storage
[Rails] Show avatars in posts using Active Storage
How to link images using FactoryBot Active Storage