class Baby
  belongs_to :child
  attr :is_public
  scope :public, includes(:child).merge(Child.public).where('babies.is_public IS TRUE')
end
class Child
  belongs_to :parent
  attr :is_public
  scope: public, where ???
  def is_public; read_attribute(:is_public).blank? ? self.parent.is_public : super(); end
end
class Parent
  has_many :children
  attr :is_public
end
Is it possible to get a collection of objects of Child where if the value of attribute_a of child is NULL it should get the value from parents.attribute_a in one sql statement