# Pulling from more then on table to populate a select\_box

**URL:** <https://www.ruby-forum.com/t/pulling-from-more-then-on-table-to-populate-a-select-box/146594>\
**Category:** Rails\
**Created:** [August 22, 2008, 7:19pm UTC](https://www.ruby-forum.com/t/pulling-from-more-then-on-table-to-populate-a-select-box/146594 "2008-08-22T19:19:00Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![snantz](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/c2a13f/32.png) [@snantz](https://www.ruby-forum.com/u/snantz)\
**Post date:** [August 22, 2008, 7:19pm UTC](https://www.ruby-forum.com/t/pulling-from-more-then-on-table-to-populate-a-select-box/146594/1 "2008-08-22T19:19:00Z")

</div>

I have two tables - Hotels and HotelAllBrands - and I need to pull data  
from both tables to fill in a select\_box. Current I am just pulling from  
one:

\<%= select( “hotelmembership”, “hotel\_id”, Hotel.find( :all,  
:order=\> ‘name’ ).collect {|h| [h.name, h.id]},  
{ :include\_blank =\> FALSE }) %\>

How do I make the above select also pull from the other table? Thanks,

-S

---

<div class="post-metadata">

**Author:** ![snantz](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/c2a13f/32.png) [@snantz](https://www.ruby-forum.com/u/snantz)\
**Post date:** [August 23, 2008, 12:19am UTC](https://www.ruby-forum.com/t/pulling-from-more-then-on-table-to-populate-a-select-box/146594/2 "2008-08-23T00:19:07Z")

</div>

Hi Shandy,

Shandy N. wrote:

> I have two tables - Hotels and HotelAllBrands - and I  
> need to pull data from both tables to fill in a select\_box.  
> Current I am just pulling from one:
> 
> \<%= select( “hotelmembership”, “hotel\_id”, Hotel.find( :all,  
> :order=\> ‘name’ ).collect {|h| [h.name, h.id]},  
> { :include\_blank =\> FALSE }) %\>
> 
> How do I make the above select also pull from the other table?

The easiest (and IMHO opinion, the most appropriate MVC) way is to do  
the  
finds in your controller, combine the results into a single instance  
variable, and feed the select with that.

HTH,  
Bill
