データベースを Ruby でモデル化しようとしていますが、その方法がわかりません。
これは私がこれまでに持っているものです:
class Course < ActiveRecord::Base
has_many :enrolled_ins
has_many :users, :through => :enrolled_ins
has_many :events, :dependent => :destroy
end
class User < ActiveRecord::Base
has_many :enrolled_ins
has_many :courses, :through => :enrolled_ins
end
class EnrolledIn < ActiveRecord::Base
belongs_to :users
belongs_to :courses
end
class Event < ActiveRecord::Base
belongs_to :courses
end
ユーザーがコースを選択すると、そのコースで必要なさまざまなイベントを選択でき、すべてのイベントを取得する代わりにそれらが割り当てられることを追加したいと思います。