I have some code to display a long list of languages inside Rails form and would like to display only one language as selectable item. The rest should not be listed but still be in the collection (its a database table holding all countries)
I have this code:
= f.input :state_id,
:label => "Your country",
:collection => DataCountry.all,
:value => @city,
:id => "city_id",
:name => "city_id"
How could I list only one language with this?
By selecting the country you want instead of passing all of them as the
:collection. This will only use the first one, but you could also use[DataCountry.find_by_whatever...]:Note that, because you’re selecting a single
DataCountry, you must wrap it in[]so that you’re passing an array as the:collection.