Forum: Ruby on Rails ActiveRecord, Squeel: Getting objects without parent associations

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
Ed675c79ccad4b43a73564eae5ef9bab?d=identicon&s=25 Alexander Kurakin (kuraga)
on 2013-10-11 06:49
I have:

class ThingsCollection < ActiveRecord::Base
  has_and_belongs_to_many :things, uniq: true
end

class Thing < ActiveRecord::Base
  has_and_belongs_to_many :things_collections, uniq: true
end

I want to get Things which don't have any ThingsCollections
(thing.things_colllection_ids.empty? == true). How can I do this via
ActiveRecord & Squeel? (Without SQL query if possible)
This topic is locked and can not be replied to.