# Search across models

**URL:** <https://www.ruby-forum.com/t/search-across-models/163229>\
**Category:** Rails\
**Created:** [March 18, 2009, 1:34pm UTC](https://www.ruby-forum.com/t/search-across-models/163229 "2009-03-18T13:34:44Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![srikanth](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/f9ae1b/32.png) [@srikanth](https://www.ruby-forum.com/u/srikanth)\
**Post date:** [March 18, 2009, 1:34pm UTC](https://www.ruby-forum.com/t/search-across-models/163229/1 "2009-03-18T13:34:44Z")

</div>

Hi all,  
I am trying to implement the search across models.  
But i could not able to do this.

let me tell you my application details:

i have tables like:

1)containerformats :  
contains the streamnames

2)transportstreams :  
have how many programs are there in each stream of  
containerformattable  
and has containerformat\_id as one column

3)programs:  
have how many video and audio streams are there in each program  
and has transportstream\_id as one column

4)streams :  
which will have the video and audio stream parametes  
and it has all other table ids like:  
transportstream\_id  
containerformat\_id  
program\_id

and i have association like:

containerformats has\_many:transportstreams  
transportstreams has\_many:programs  
programs has\_many:streams  
streams belongs\_to :all above tables

I have cretaed a search controller to implement the search:  
now here my sample querie i want to implement in my search controller.

find streams from containerformats has number of programs = 1(which is  
from transportstreams table) and nummberof videos =1 (which is from  
programs table) and resolution =“720x480”(which is from streams table)

the above query i could able to write and test in mysql prompt.  
But if i try to implement this i could not able to do this.  
Can you suggest me how exactly the code looks like to search the data  
from a table based on other table parametrs selected?

suggest me if iam doing any mistake while assigning associatioons.

Any help would be appreciated.

thanks  
Srikanth
