2
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

Carrierwaveの導入

Posted at

インストール

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

2
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
2
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?