开发者

select_tag with options_for_select

My platform is:

Windows7 x64,

ruby 1.8.7 (2010-01-10 patchlevel 249) [i386-mingw32],

Rails 2.3.8

<%= select_tag 'locale', options_for_select(LANGUAGES, I18n.locale),
    :onchange => 'this.form.submit()' %>

LANGUAGES looks like:

LANGUAGES = {
  'English' => 'en',
  "Espa\xc3\xb1ol" => 'es'
}

Despite the fact, that I18n.locale is equal to 'en'开发者_JS百科, 'English' value is not selected.

<select id="locale" name="locale" onchange="this.form.submit()">
   <option value="es">Español</option>
   <option value="en">English</option>
</select>  

I'm totally stuck. I can't figure out what's the problem. Any ideas?

Update: I have figured it out. I had to add to_s:

options_for_select(LANGUAGES, I18n.locale.to_s)

Thanks, Alpha.


I had to add to_s:

options_for_select(LANGUAGES, I18n.locale.to_s)
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜