I need to find parents that either have no child OR have all children exclusively with condition (status = 1).
class Parent
has_many :children
end
class Child
enum status: [ :confirmed, :not_confirmed ]
belongs_to :parent
end
I know the first part, which is finding parents with no children.
Parent.joins(:children).where('count(children) = 0')
Rails answer.