aboutsummaryrefslogtreecommitdiffstats
path: root/activemodel/lib
diff options
context:
space:
mode:
authorAndrew White <andrew.white@unboxed.co>2019-01-20 10:19:07 +0000
committerAndrew White <andrew.white@unboxed.co>2019-01-21 09:23:12 +0000
commitccdedeb9d5e1b2b74f03baef65aa8198b456e3b0 (patch)
treeaa974b0826ded5979d79ba05e06793d3c27ccad8 /activemodel/lib
parent31e118c39dc50a5ffeffe2b745a26b4c56651a35 (diff)
downloadrails-ccdedeb9d5e1b2b74f03baef65aa8198b456e3b0.tar.gz
rails-ccdedeb9d5e1b2b74f03baef65aa8198b456e3b0.tar.bz2
rails-ccdedeb9d5e1b2b74f03baef65aa8198b456e3b0.zip
Fix year value when casting a multiparameter time hash
When assigning a hash to a time attribute that's missing a year component (e.g. a `time_select` with `:ignore_date` set to `true`) then the year defaults to 1970 instead of the expected 2000. This results in the attribute changing as a result of the save. Before: event = Event.new(start_time: { 4 => 20, 5 => 30 }) event.start_time # => 1970-01-01 20:30:00 UTC event.save event.reload event.start_time # => 2000-01-01 20:30:00 UTC After: event = Event.new(start_time: { 4 => 20, 5 => 30 }) event.start_time # => 2000-01-01 20:30:00 UTC event.save event.reload event.start_time # => 2000-01-01 20:30:00 UTC
Diffstat (limited to 'activemodel/lib')
-rw-r--r--activemodel/lib/active_model/type/time.rb2
1 files changed, 1 insertions, 1 deletions
diff --git a/activemodel/lib/active_model/type/time.rb b/activemodel/lib/active_model/type/time.rb
index b3056b1333..8fba01b86a 100644
--- a/activemodel/lib/active_model/type/time.rb
+++ b/activemodel/lib/active_model/type/time.rb
@@ -5,7 +5,7 @@ module ActiveModel
class Time < Value # :nodoc:
include Helpers::TimeValue
include Helpers::AcceptsMultiparameterTime.new(
- defaults: { 1 => 1970, 2 => 1, 3 => 1, 4 => 0, 5 => 0 }
+ defaults: { 1 => 2000, 2 => 1, 3 => 1, 4 => 0, 5 => 0 }
)
def type