2010-07-21 60 views
0

我有以下select()形式的輔助方法:Rails:手動更改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> 

回答

1

相反的散列,去陣列

<%= select("treatment", "frequency_unit", %w{hour day week month year})%>