ActiveRecord, Squeel: Getting objects without parent associations

14 views
Skip to first unread message

Alexander Kurakin

unread,
Oct 11, 2013, 12:49:12 AM10/11/13
to rubyonra...@googlegroups.com
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)

--
Posted via http://www.ruby-forum.com/.
Reply all
Reply to author
Forward
0 new messages