rails date_select のプルダウン間の区切り文字
rails の date_select を使って、プルダウンの間に、"年" や "月" 等の日本語の文字を
表示できないかと悩んだ。
date_separatorを%sにして、sprintfで置換するのがお手軽かな?
<% form_for @my_model, :url => { :action => 'create' } do |f| %> <%= sprintf( f.date_select( :nengetsu, :order => [:year, :month, :day], :discard_day => true, :use_month_numbers => true, :date_separator => '%s' ), '年 ', '月', '' ) %> <% end %>
上記はこんな感じで出力される。
年 月