diff options
author | Kasper Timm Hansen <kaspth@gmail.com> | 2017-01-15 21:53:57 +0100 |
---|---|---|
committer | Kasper Timm Hansen <kaspth@gmail.com> | 2017-01-15 21:53:57 +0100 |
commit | a5632d84957139aa2d471703b22edc095b21ea78 (patch) | |
tree | 1fad0c283bbb43435f3bc2bbfae0f5cae8801dad | |
parent | f8a3981beb4221c230a2dc366db5fcc5e276f035 (diff) | |
download | rails-a5632d84957139aa2d471703b22edc095b21ea78.tar.gz rails-a5632d84957139aa2d471703b22edc095b21ea78.tar.bz2 rails-a5632d84957139aa2d471703b22edc095b21ea78.zip |
Revert "Don't guard against `touch: []`."
`timestamp_attributes_for_updates_in_model` returns an empty
array when a model has no `updated_at` or `updated_on`.
So my previously thought uncommon case is a lot more likely
now.
This reverts commit a0a1ede8c2eb6436571eae8778033162d1f9dcc3.
-rw-r--r-- | activerecord/lib/active_record/counter_cache.rb | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/activerecord/lib/active_record/counter_cache.rb b/activerecord/lib/active_record/counter_cache.rb index 93b9371206..cbd71a3779 100644 --- a/activerecord/lib/active_record/counter_cache.rb +++ b/activerecord/lib/active_record/counter_cache.rb @@ -105,7 +105,8 @@ module ActiveRecord end if touch - updates << sanitize_sql_for_assignment(touch_updates(touch)) + touch_updates = touch_updates(touch) + updates << sanitize_sql_for_assignment(touch_updates) unless touch_updates.empty? end unscoped.where(primary_key => id).update_all updates.join(", ") |