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

Popular posts from this blog

linux - Using a Cron Job to check if my mod_wsgi / apache server is running and restart -

actionscript 3 - TweenLite does not work with object -

jQuery Ajax Render Fragments OR Whole Page -