I’ve got the hang of nested includes—they’re great for performance—but what I’d really like is a ‘nested find’. What’s the best way to achieve something like:
@matchingProducts = Batch.find(:all,
:conditions => 'product.name LIKE ?', "%#{search}%",
:include => :product)
As you can see, Product is a nested attribute of Batch, but I want to find a batch based on Product.name.
Rails 3 I would use the AREL syntax: