ActiveRecord - Select relations exist records in scope

12 Jul 2019

select relations exist records in scope

scope :children_exists, lambda {
  left_joins(:children).where('children.parent_id IS NOT NULL')
}