Railsで多用しているselect_tagは初期値(デフォルト)を明示的に設定しないといけない?らしい。

データ自体はintegerだが、テキストボックスに入力させるのが嫌なので
[[1, 1], ..., [99, 99]]の配列をoptions_for_selectでoptionに突っ込んだ。

が、editのときにオブジェクトの値が反映されない。

Before

# @numbers = [[1, 1], ..., [99, 99]]
<%= f.select :number, options_for_select(@numbers)%>

リファレンスを見ると、:selectedオプションがあるじゃないか。

After

# @numbers = [[1, 1], ..., [99, 99]]
<%= f.select :number, options_for_select(@numbers, selected: @user[:number])%>

これでeditの場合でも値が反映されるようになる。

selectのオプションが中身をすべてeditするモデルと関連付けられたモデルになっている?場合、
わざわざselectedオプションを指定しなくても動作するようだ。