I have this code:
<%= f.label :lang %><br />
<%= f.select :lang_id, @langs %>
it generates html like that:
<label for="entry_lang">Lang</label><br />
<select id="entry_lang_id" name="entry[lang_id]">
<option value="pl">1</option>
<option value="en">2</option>
</select>
Now I want to have "pl" and "en" visible for user, not integers. So I tried:
<%= f.label :lang %><br开发者_如何学Python />
<%= f.select :lang_name, @langs %>
And it doesn't work. How to do it right?
It looks like your @langs array is in the format:
[[1, "pl"], [2, "en"], ....]
It should be the other way around; display name first, then id:
[["pl", 1], ["en", 2], ....]
精彩评论