So let's say I have this:
class Tree < ActiveRecord::Base
has_many :fruits
has_many :flowers
end
class Fruit < ActiveRecord::Base
belongs_to :tree
end
class Flower < ActiveRecord::Base
belongs_to :tree
end
How can I make an efficient query that would get all the Tree
instances that would have at least one Flower
or Fruit
instance, or both? The idea is not getting the Tree
that don't have any Flower
and Fruit
at all.