# HABTM pregunta

**URL:** <https://www.ruby-forum.com/t/habtm-pregunta/167463>\
**Category:** Rails\
**Created:** [May 8, 2009, 12:08am UTC](https://www.ruby-forum.com/t/habtm-pregunta/167463 "2009-05-08T00:08:14Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![bigdaddy71](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/bbe5ce/32.png) [@bigdaddy71](https://www.ruby-forum.com/u/bigdaddy71)\
**Post date:** [May 8, 2009, 12:08am UTC](https://www.ruby-forum.com/t/habtm-pregunta/167463/1 "2009-05-08T00:08:14Z")

</div>

I have 2 habtm relations:

FORM \<- HABTM-\> COMPANIES  
FORM \<- HABTM -\> SITES

Is there an easy way to do a query like:

Find out what sites belong to what company related to the form?

Also is there a better or more efficient way of setting this kind of  
scenario up?

The FORM can have multiple companies associated as well as multiple  
sites belonging to each company.
