0
0

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.

ActiveStorageの実装方法

Posted at

#Acitive Storageを使う際の備忘録
##ImageMagickのインストール
brew install imagemagick
##MiniMagickのインストール
-imagemagickをrubyで使えるようにしてくれるgem
Gemfile
gem 'mini_magick'
ターミナル
bundle install
##ImageProcessingのインストール
-画像サイズを調整するgem
Gemfile
gem 'image_processing'
ターミナル
bundle install
サーバーの再起動
rails s
##Active_Storageをインストール
-マイグレーション の作成
ターミナル
rails active_storage:install
rails db:migrate
##modelにhas_one_attachedメソッドを記述
-テーブルに画像を紐付ける
has_one_attached :image
##コントローラーで画像の保存を許可する
params.permit(:image)

0
0
1

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
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?