Find with Inheritance

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.

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs