2011-12-14 48 views
0

我无法确定如何使用select_month将默认月份设置为4。不知道我做错了什么。谢谢。设置调用时的默认值select_month

select_month(Date.today, 
      :field_name => 'month', 
     :use_month_numbers => true, 
     :html_options => { :selected => '4'}) 

回答

4

我觉得这里你需要使用Date.new(2011年4)代替Date.today设置默认

select_month(Date.new(2011, 4), 
      :field_name => 'month', 
      :use_month_numbers => true) 
+0

是的,这是有效的。谢谢。 – user612308 2011-12-14 16:46:40

0

我能得到这个简单的使用当前日期

select_month Date.today.month, {add_month_numbers: true} 
1

我在信用卡形式使用实现了这个:

select_month 6, { add_month_numbers: true } 
0,我的信用卡形式的伟大工程

以6月为默认值呈现。我用这个来渲染用户在cc表单被重新渲染时选择的月份。我实际上并没有硬代码6.