Shandy Nantz
2008-Aug-22 17:19 UTC
Pulling from more then on table to populate a select_box
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 -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Bill Walton
2008-Aug-22 17:38 UTC
Re: Pulling from more then on table to populate a select_box
Hi Shandy, Shandy Nantz 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 --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---