手順 メインモデル作成
① rails g model (モデル名)
② マイグレーションファイルに必要なカラムを記述、Userモデルと紐づける必要があるなら、
t.references :user, foreign_key: true
みたいに記述
③ rails db:migrateでテーブル作成
モデル
① バリデーション、アソシエーションの作成
② 写真等の投稿がある場合
ⅰ) Gemfileにgem 'mini_magick' gem 'image_processing', '~> 1.2'を記述して
bundle install
ⅱ) rails active_storage:installでActive Storage導入してrails db:migrate
ⅲ) そのモデルにバリデーション、アソシエーションの設定
has_one_attached :image
validates :image, presence: true
コントローラー、ルーティング
① 使用するアクションの記述
コントローラ
def index
end
ルーティング
resources :(コントローラー名) only: :index
みたいに