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