インストール
terminal
brew install imagemagick
Gemfile
gem 'carrierwave'
gem 'mini_magick'
terminal
$ bundle install
$ rails g uploader image
Messageモデルに、image_uploaderをマウントする
app/models/message.rb
class Message < ApplicationRecord
mount_uploader :image, ImageUploader
end
app/uploaders/image_uploader.rb
class ImageUploader < CarrierWave::Uploader::Base
# Include RMagick or MiniMagick support:
# include CarrierWave::RMagick
include CarrierWave::MiniMagick
# storage :fog
process resize_to_fit: [800, 800]
end