# Acts a tsearch search multiple models

**URL:** <https://www.ruby-forum.com/t/acts-a-tsearch-search-multiple-models/143749>\
**Category:** Rails\
**Created:** [July 22, 2008, 1:36pm UTC](https://www.ruby-forum.com/t/acts-a-tsearch-search-multiple-models/143749 "2008-07-22T13:36:56Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![johnnybutler7](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/8491ac/32.png) [@johnnybutler7](https://www.ruby-forum.com/u/johnnybutler7)\
**Post date:** [July 22, 2008, 1:36pm UTC](https://www.ruby-forum.com/t/acts-a-tsearch-search-multiple-models/143749/1 "2008-07-22T13:36:56Z")

</div>

Hi,

I have a Job model and a location model. So ajob belongs to a location  
and a location can have many jobs.

Im trying to use acts as tsearch to search for keywords that match  
everything in the Jobs and Locations table.

How do i specify to search the relationship model.

acts\_as\_tsearch :vectors =\> {  
:local =\> “default”,  
:auto\_update\_index =\> true,  
:fields =\> {  
“a” =\> {:columns =\> [“jobs.title”], :weight =\> 1},  
“b” =\> {:columns =\> [“locations.name”], :weight =\> 0.4}  
},  
:tables =\> {  
:locations =\> {  
:from =\> “locations left outer join  
jobs on locations.id = jobs.location\_id”,  
:where =\> “jobs.location\_id = locations.id”  
}  
}

}  
I also tried @jobs = Job.find\_by\_tsearch(query, :include =\> :location,  
:limit =\> :all)

but im not getting what i expect back.

everything in the jobs table is coming bakc onk but nothing for the  
locations.

Anybody help?

JB
