ActiveStorage Gem that can implement file upload function
ImageMagick Software that can perform image processing from the command line You can create images, change the size, and change the save format. To handle the software ImageMagic with Rails, a gem called MiniMagic is required.
MiniMagick Gem for using ImageMagic features in Ruby
ImageProcessing Gem that adds the ability to adjust the image size Add image size adjustments that cannot be done with ImageMagic alone.
Install from Homebrew Terminal
% brew install imagemagick
Added to the bottom layer of Gemfile
Gemfile
gem 'mini_magick'
gem 'image_processing', '~>1.2'
Terminal
% bundle install
Enable Active Storage
Terminal
% rails active_storage:install
Executing the above command will generate a migration file related to Active Storage. Don't forget to migrate.
Terminal
% rails db:migrate
has_one_attached A method for creating a one-to-one association between records and files
model.rb
class model< ApplicationRecord
has_one_attached :file name
end
Add the file name described above to the strong parameter.
Recommended Posts