aboutsummaryrefslogtreecommitdiffstats
path: root/actionpack/lib/action_view/helpers/date_helper.rb
diff options
context:
space:
mode:
authorBernardo de Pádua <berpasan@gmail.com>2008-11-04 00:28:17 -0200
committerDavid Heinemeier Hansson <david@loudthinking.com>2008-11-04 18:15:54 +0100
commitb2cd318c2e3f4d19813a5c62903319a6683aa561 (patch)
treef30348da0b0661a4351a9c2d171e199db3ceee96 /actionpack/lib/action_view/helpers/date_helper.rb
parenta909eecbbd42e70a5bc0e099485f07dc64db5d38 (diff)
downloadrails-b2cd318c2e3f4d19813a5c62903319a6683aa561.tar.gz
rails-b2cd318c2e3f4d19813a5c62903319a6683aa561.tar.bz2
rails-b2cd318c2e3f4d19813a5c62903319a6683aa561.zip
Fix regression bug that made date_select and datetime_select raise a Null Pointer Exception when a nil date/datetime was passed and only month and year were displayed [#1289 state:committed]
Signed-off-by: David Heinemeier Hansson <david@loudthinking.com>
Diffstat (limited to 'actionpack/lib/action_view/helpers/date_helper.rb')
-rw-r--r--actionpack/lib/action_view/helpers/date_helper.rb4
1 files changed, 2 insertions, 2 deletions
diff --git a/actionpack/lib/action_view/helpers/date_helper.rb b/actionpack/lib/action_view/helpers/date_helper.rb
index d4d2c6ef53..919c937444 100644
--- a/actionpack/lib/action_view/helpers/date_helper.rb
+++ b/actionpack/lib/action_view/helpers/date_helper.rb
@@ -539,7 +539,7 @@ module ActionView
# If the day is hidden and the month is visible, the day should be set to the 1st so all month choices are
# valid (otherwise it could be 31 and february wouldn't be a valid date)
- if @options[:discard_day] && !@options[:discard_month]
+ if @datetime && @options[:discard_day] && !@options[:discard_month]
@datetime = @datetime.change(:day => 1)
end
@@ -567,7 +567,7 @@ module ActionView
# If the day is hidden and the month is visible, the day should be set to the 1st so all month choices are
# valid (otherwise it could be 31 and february wouldn't be a valid date)
- if @options[:discard_day] && !@options[:discard_month]
+ if @datetime && @options[:discard_day] && !@options[:discard_month]
@datetime = @datetime.change(:day => 1)
end
end