When creating the original application, we implemented a function to post images, so I will post it so that I will not forget it. There were various methods when I looked it up with Qiita etc., but this time I used a function called Active Storage of Rails.
% brew install imagemagick
gem 'mini_magick' gem 'image_processing', '~> 1.2'
This time we will implement it assuming that it will be entwined with the Post table
class Post < ApplicationRecord has_one_attached :image end
#Omission private def post_params params.require(:post).permit(:hoge, :fuga, :image) end
Display an image using the image_tag method
#Omission <div class='post'> <%= image_tag post.image, class: 'post-image' %> </div>