diff options
author | Carlos Antonio da Silva <carlosantoniodasilva@gmail.com> | 2012-11-25 14:29:34 -0800 |
---|---|---|
committer | Carlos Antonio da Silva <carlosantoniodasilva@gmail.com> | 2012-11-25 22:55:20 -0200 |
commit | 6fe1a4a2da5440aee91c4de387ffdf71b0b83a0e (patch) | |
tree | 7c648455a52abc85382753b8de456660993076c9 /activerecord/lib/active_record/attribute_methods | |
parent | 83e71051258b98bd5c4df80b321c7b690ddcab35 (diff) | |
download | rails-6fe1a4a2da5440aee91c4de387ffdf71b0b83a0e.tar.gz rails-6fe1a4a2da5440aee91c4de387ffdf71b0b83a0e.tar.bz2 rails-6fe1a4a2da5440aee91c4de387ffdf71b0b83a0e.zip |
Merge pull request #8311 from alisdair/dirty-nullable-datetime
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.
Conflicts:
activerecord/CHANGELOG.md
activerecord/lib/active_record/attribute_methods/time_zone_conversion.rb
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 4c3d5eed4c..39d81cf6ef 100644 --- a/activerecord/lib/active_record/attribute_methods/time_zone_conversion.rb +++ b/activerecord/lib/active_record/attribute_methods/time_zone_conversion.rb @@ -37,6 +37,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 |