1.基本用法
<%= f.select :rank, options_for_select(Archive::Ranks) %> Archive::Ranks是数组 用%w构建即可 2. 在修改时反映数据库里的值 用 <%= f.select :rank, options_for_select(Archive::Ranks) %> 时,选择框里的值不正确 应如下: 档案类别<br /> <%= f.select :category, options_for_select(Archive::Categorys,:selected => [@archive.category]) %><%= f.select :category, options_for_select(Archive::Categorys, :selected => [@archive.category]), {},:class => 'form-control', 'data-style' => "btn-primary"%>
要注意()号,也不能这样写: <%= f.select :category, options_for_select(Archive::Categorys),:selected => [@archive.category] %>