On 4/26/07, Ivor P. email@example.com wrote:
Sure, I assume you do a query for the countries -> @countries =
for starters do this
@countries = Country.find(:all, :include => ‘languages’) which will get the
languages in the same query.
Now, in the select you have options_for_select=[array] so you have to build
an array that looks like this [“USA -
I believe you’d actually need something like:
[ [“USA-English”, “USA”], [“France-French”, “French”], … ]
so that you’re providing both a label and a value for each option.
I would suggest that you create a helper method
reponse_array = 
country_array.each do |country|
response_array << country.name + " - " + country.language.name
You’ve just reimplemented map You can let Ruby do more of the
countries.map do |country|
[country.name + ‘-’ + country.language.name, country.name]
You could also use country.id instead of country.name for the value,
which might make it slightly easier to pull the record later.
Upcoming Rails training by Ruby Power and Light:
Four-day Intro to Intermediate
May 8-11, 2007