调用select_month时设置默认值

use*_*308 0 ruby-on-rails ruby-on-rails-3

我无法使用select_month计算如何将默认月份设置为4.不知道我做错了什么.谢谢.

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

alo*_*ony 5

我想在这里你需要使用Date.new(2011,4)而不是Date.today来设置默认值

select_month(Date.new(2011, 4),  
             :field_name => 'month', 
             :use_month_numbers => true)
Run Code Online (Sandbox Code Playgroud)