I'm trying to find all Foo
's that don't have a Bar
associated with them. I know this doesn't work but something along the lines of Foo.where(barable: nil)
.
Foo model
class Foo < ApplicationRecord
has_many :bars, as: :barable
end
Bar model
class Bar < ApplicationRecord
belongs_to :barable, polymorphic: true
end
Tables
Foo(id: integer, name: string, created_at: datetime, updated_at: datetime)
Bar(id: integer, barable_type: string, barable_id: string, created_at: datetime, updated_at: datetime)