There is a function that often uploads images on SNS, but I will introduce the Gem used when implementing it in Rails. Since it will be long, I will focus on the preparation stage of implementation this time. Scheduled twice in total.
It's now included in Rails without having to install it as a Gem. You will be able to use methods that make it easy to upload files such as images, and you can easily create a table to save images.
In the first place, ImageMagick is an image processing tool, not a Gem, but a category of software. When installing from Homebrew
brew install imagemagick
ImageMagick alone cannot handle it in Ruby, so you need to install the following two gems.
(1)MiniMagick ImageMagick features will be available in Ruby. (2)ImageProcessing Adjust the size of the image, which cannot be done with MiniMagick alone.
gem 'mini_magick' gem 'image_processing', '~>1.2' #Specifying the version
OK at the bottom of the Gemfile. After writing, don't forget to use the terminal
Don't forget when you newly install Gem.
It was sunny and Active Storage became available, so Install using the terminal
When installed, a migration file will be generated automatically.
If there is no particular column change, leave it as it is
Confirm that two tables are generated by this migration.
-[x] Implement the image upload function using ActiveStorage. -[x] Install two gems so that they can be used in Ruby.
Next time, I will summarize how to save images and how to display saved images.