Reputation: 459
I have a typical has_many :through relationship between Menu and Section called Sectionalization. Sections go on Menus. Some Sections are on no Menu.
I need a collection of all the Section records for which there is no Sectionalization record with a matching section_id (Sections that are on NO other Menu).
Upvotes: 0
Views: 175
Reputation: 29389
As far as I know this requires an outer join which in turn requires that you specify it with your own SQL fragment, as follows:
Section.joins('LEFT OUTER JOIN sectionalizations on sections.id = sectionalizations.section_id).where('sectionalizations.section_id IS NULL)
Upvotes: 1