From db6179d12f06895aa3d813c495ff77bbddf439d1 Mon Sep 17 00:00:00 2001 From: David Heinemeier Hansson Date: Wed, 15 Dec 2004 12:47:50 +0000 Subject: Fixed DateHelper#date_select so that you can pass include_blank as an option even if you don't use start_year and end_year #59 [what-a-day] git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@167 5ecf4fe2-1ee6-0310-87b1-e25e094e27de --- actionpack/lib/action_view/helpers/date_helper.rb | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'actionpack/lib') diff --git a/actionpack/lib/action_view/helpers/date_helper.rb b/actionpack/lib/action_view/helpers/date_helper.rb index 8af3afb034..58dab783d5 100755 --- a/actionpack/lib/action_view/helpers/date_helper.rb +++ b/actionpack/lib/action_view/helpers/date_helper.rb @@ -158,7 +158,8 @@ module ActionView # select_year(Date.today, :start_year => 1992, :end_year => 2007) def select_year(date, options = {}) year_options = [] - unless date.kind_of?(Fixnum) then default_start_year, default_end_year = date.year - 5, date.year + 5 end + y = date.kind_of?(Fixnum) ? (y = (date == 0) ? Date.today.year : date) : date.year + default_start_year, default_end_year = y-5, y+5 (options[:start_year] || default_start_year).upto(options[:end_year] || default_end_year) do |year| year_options << ((date.kind_of?(Fixnum) ? date : date.year) == year ? -- cgit v1.2.3