ruby on rails - Using select_month in form_for -
i working in ruby on rails , cant figure out how use select_month in form_for. trying is
<%= form_for(@farm) |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 %>
wich outputting
["harvest_start", nil]
thank help. sorry if formatting incorrect.
(this answered in comments t. weston kendall making proper answer)
the following code got work.
_form.html.erb
<div class="field"> <%= f.label :harvest_start %><br /> <%= f.collection_select :harvest_start, farm::months, :to_s, :to_s, :include_blank => true %> </div>
farms_controller.rb
@farm.harvest_start = params[:harvest_start]
i got select_month work needed :include_blank
, didn't want spend time figuring out nil in array.
Comments
Post a Comment