我有以下select()
表单帮助方法:
select("treatment", "frequency_unit", { "hour" => "hour", "day" => "day", "week" => "week", "month" => "month", "year" => "year" })
帮助者正在组织看似随机的选择...我希望它能保持选择的顺序,就像上面列出的那样。
我怎样才能实现这一目标?
以下是上述代码的输出:
<select id="treatment_frequency_unit" name="treatment[frequency_unit]">
<option value="month">month</option>
<option value="week">week</option>
<option value="hour">hour</option>
<option value="day">day</option>
<option value="year">year</option>
</select>
答案 0 :(得分:1)
而不是哈希,去一个数组
<%= select("treatment", "frequency_unit", %w{hour day week month year})%>