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

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)
Please log in before posting. Registration is free and takes only a minute.
Existing account

NEW: Do you have a Google/GoogleMail, Yahoo or Facebook account? No registration required!
Log in with Google account | Log in with Yahoo account | Log in with Facebook account
No account? Register here.