# Find with polymorphic associations

**URL:** <https://www.ruby-forum.com/t/find-with-polymorphic-associations/156254>\
**Category:** Rails\
**Created:** [December 23, 2008, 3:02pm UTC](https://www.ruby-forum.com/t/find-with-polymorphic-associations/156254 "2008-12-23T15:02:09Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![df-sean](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/f07891/32.png) [@df-sean](https://www.ruby-forum.com/u/df-sean)\
**Post date:** [December 23, 2008, 3:02pm UTC](https://www.ruby-forum.com/t/find-with-polymorphic-associations/156254/1 "2008-12-23T15:02:09Z")

</div>

I have an Order model which has\_many Shipments and has\_many  
Creditcards. In my controller I’m trying to process various search  
parameters so that I can search on a customer name. I’d like to match  
on the name in any of the shipments or creditcards.

I’m just not sure how to structure the conditions so that the Address  
table is included since Address belongs\_to addressable, :polymorphic  
=\> true.

TIA,

Sean

---

<div class="post-metadata">

**Author:** ![df-sean](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/f07891/32.png) [@df-sean](https://www.ruby-forum.com/u/df-sean)\
**Post date:** [December 23, 2008, 3:41pm UTC](https://www.ruby-forum.com/t/find-with-polymorphic-associations/156254/2 "2008-12-23T15:41:00Z")

</div>

I made some progress with the following

Order.find(:all, :include =\> [{:shipments =\> :address}, {:creditcards  
=\> :address}], :conditions =\> [“lower(addresses.firstname) LIKE ?”,  
"%frank%])

This works but only for the shipping addresses. but it won’t find the  
creditcard address. Any ideas?

TIA,

Sean
