我想将此哈希用作 f.select 的文本和值列表
控制器
@asset_status_options = [ { "New - Ordered" => "0" },
{ "New - On Site" => "10" },
{ "New - Tested" => "99" },
{ "Used - Ordered" => "1" },
{ "Used - On Site" => "11" },
{ "Used - Torn Down" => "25" },
{ "Used - Rebuilt" => "76" },
{ "Used - Tested" => "100"}]
看法
<%= m.select :status, options_for_select(@asset_status_options,"") %>
下拉的结果是:
{ "New - Ordered" => "0" }
{ "New - On Site" => "10" }
{ "New - Tested" => "99" }
{ "Used - Ordered" => "1" }
{ "Used - On Site" => "11" }
{ "Used - Torn Down" => "25" }
{ "Used - Rebuilt" => "76" }
{ "Used - Tested" => "100"}
我正在寻找值 0 和 New - Ordered 等文本。
我觉得很简单,但我该怎么做?