diff options
author | Alisdair McDiarmid <alisdair@mcdiarmid.org> | 2012-11-25 10:13:39 +0000 |
---|---|---|
committer | Alisdair McDiarmid <alisdair@mcdiarmid.org> | 2012-11-25 11:24:27 +0000 |
commit | fc4e387d7a478f75cdd4375b6c62e918b4b132b0 (patch) | |
tree | e993fe9626595504f388f4f3d8dd48c17a7faf94 /activerecord/lib/active_record/attribute_methods | |
parent | e95b9d6c68b1e0bba3840d18fc0aa94ccf88776d (diff) | |
download | rails-fc4e387d7a478f75cdd4375b6c62e918b4b132b0.tar.gz rails-fc4e387d7a478f75cdd4375b6c62e918b4b132b0.tar.bz2 rails-fc4e387d7a478f75cdd4375b6c62e918b4b132b0.zip |
Don't call will_change! for datetime nil->"".
Setting a nil datetime attribute to a blank string should not cause the
attribute to be dirty.
Fix #8310
Diffstat (limited to 'activerecord/lib/active_record/attribute_methods')
-rw-r--r-- | activerecord/lib/active_record/attribute_methods/time_zone_conversion.rb | 1 |
1 files changed, 1 insertions, 0 deletions
diff --git a/activerecord/lib/active_record/attribute_methods/time_zone_conversion.rb b/activerecord/lib/active_record/attribute_methods/time_zone_conversion.rb index 427c61079a..47a8b576c0 100644 --- a/activerecord/lib/active_record/attribute_methods/time_zone_conversion.rb +++ b/activerecord/lib/active_record/attribute_methods/time_zone_conversion.rb @@ -34,6 +34,7 @@ module ActiveRecord if create_time_zone_conversion_attribute?(attr_name, columns_hash[attr_name]) method_body, line = <<-EOV, __LINE__ + 1 def #{attr_name}=(original_time) + original_time = nil if original_time.blank? time = original_time unless time.acts_like?(:time) time = time.is_a?(String) ? Time.zone.parse(time) : time.to_time rescue time |