# Find with Inheritance

**URL:** <https://www.ruby-forum.com/t/find-with-inheritance/136817>\
**Category:** Rails\
**Created:** [May 6, 2008, 5:21pm UTC](https://www.ruby-forum.com/t/find-with-inheritance/136817 "2008-05-06T17:21:46Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![casper\_the\_ghost](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/58956e/32.png) [@casper\_the\_ghost](https://www.ruby-forum.com/u/casper_the_ghost)\
**Post date:** [May 6, 2008, 5:21pm UTC](https://www.ruby-forum.com/t/find-with-inheritance/136817/1 "2008-05-06T17:21:46Z")

</div>

Hi,

I have the following structure with my models:

A member inherits from a company  
A applicant inherits from a company

An application has an applicant  
An application has a member

I am attempting to do a find on the applications table where the  
search term either matches the applicant name or the member name.

So far I have the following find statement:

Application.paginate(:all,  
:conditions =\>  
[(["(LOWER(companies.name) LIKE ?)"] \* terms.size).join(" AND "), \*  
terms.flatten], :include =\> [:applicant, :member], :per\_page =\>  
10, :page =\> page, :order =\> ‘applications.id desc’)

It seems as if rails creates the first join in sql normally, but then  
creates the second join and gives it the name: members\_applications. I  
could just add the condition or members\_applications.name like … but  
I don’t think this is the proper way of doing things.

Another option is to do it in multiple find statements, but I don’t  
think this is correct either.

Does anyone have a suggestion?

Thanks for your help,

Ryan L.
