我在Ruby on Rails中工作,我無法弄清楚如何在form_for中使用select_month。我試圖爲在form_for中使用select_month
<%= form_for(@farm) do |f| %>
<div class="field">
<%= f.label :harvest_start %><br />
<%= select_month(Date.today, :field_name => 'harvest_start') %>
</div>
<div class="actions">
<%= f.submit %>
</div>
<% end %>
至極的輸出
["harvest_start", nil]
感謝你的幫助。對不起,如果格式不正確。
下面的代碼是我的工作。 –
<%= f.collection_select :harvest_start, Farm::MONTHS, :to_s, :to_s, :include_blank => true %>
@ farm.harvest_start = params [:harvest_start] –