2016-05-26 11 views
0

私は今年から2015年まで、今年までは2015年から2015年に変更された年のリストを作成する必要があります。現在の年を取得する方法select_tag

<%= select_tag "leave_emp_year", options_for_select(Date.today, :start_year => Date.today.year, :end_year => 8.years.from_now.years), prompt: "Select Year", class: "leave_emp_sort_filter",style: "width:150px !important;" %> 

以前私はこの

<%= select_tag "leave_emp_year", options_for_select([[2016, 2016], [2017, 2017]]), prompt: "Select Year", class: "leave_emp_sort_filter",style: "width:150px !important;" %> 

答えて

0

あなたは

を次のようにそれはあなたのselectタグを与える次のコード

<%= select_tag "leave_emp_year", options_for_select(2015..Date.today.year), prompt: "Select Year", class: "leave_emp_sort_filter",style: "width:150px !important;" %> 

を使用することができます

0

のように行われてきたが、それは何が必要であると思います。現在の年がデフォルトで選択されます。

<%= select_tag "leave_emp_year", options_for_select(2015..Date.today.year, Date.today.year), prompt: "Select Year", class: "leave_emp_sort_filter",style: "width:150px !important;" %> 
関連する問題