ウェブサービスを作っています。

DateHelper の :include_blank に文字列を指定できるようにする

Rails 2.1.0 です。
FormOptionsHelper の :include_blank には文字列を指定できるくせに、DateHelper には true しか指定できなくてむかついたので作りました。

module ActionView::Helpers::DateHelper
  def select_html_with_useful_include_blank(type, html_options, options, select_tag_options = {})
    name_and_id_from_options(options, type)
    select_options = {:id => options[:id], :name => options[:name]}
    select_options.merge!(:disabled => 'disabled') if options[:disabled]
    select_options.merge!(select_tag_options) unless select_tag_options.empty?
    select_html = "\n"
    if options[:include_blank]
      select_html << content_tag(:option,
                                 (options[:include_blank].kind_of?(String) ?
                                  options[:include_blank] : ''),
                                 :value => '') + "\n"
    end
    select_html << html_options.to_s
    content_tag(:select, select_html, select_options) + "\n"
  end

  alias_method_chain :select_html, :useful_include_blank
end

config/initalizers/rails_ext.rb とかに入れておけば、:include_blank で文字列の指定が可能になります。
全くたいしたことないので、次期バージョンで修正されるといいなあ。