【发布时间】:2014-08-15 01:52:35
【问题描述】:
我的模型是这样写的:
class Registration < ActiveRecord::Base
has_many :registered_courses
has_many :courses, through: :registered_courses
has_many :sections, through: :courses
问题在于,如果许多不同的Registration 具有相同的Course。当我写类似的东西时:
Registration.find(x).sections
它从任何注册的相同课程中返回部分。
但我真正想要的是所有部分仅来自该特定注册。也就是说,即使其他注册正在使用相同的课程。
【问题讨论】:
标签: ruby-on-rails postgresql activerecord scope has-and-belongs-to-many