イベントを開催できるサイトをRails、Rubyを使い開発している初心者のものです。
Authorモデルと、Eventモデルを作成しました。
Eventモデルの中に、author_idというカラムを作成し、Authorモデルのidの番号と紐づけたいと考えています。
author.rb
class Author < ApplicationRecord
has_many :events, dependent: :destroy
end
event.rb
class Event < ApplicationRecord
belongs_to :author ,class_name: 'Author' ,foreign_key: 'author_id'
end
これより先はどうすればいいのでしょうか。
何卒よろしくお願いいたします。
あなたの回答
tips
プレビュー