diff options
author | Ryuta Kamizono <kamipo@gmail.com> | 2018-04-21 22:06:12 +0900 |
---|---|---|
committer | Ryuta Kamizono <kamipo@gmail.com> | 2018-04-21 22:06:12 +0900 |
commit | 611e1102d3bd46c4765bec7d57ca8d343c419e33 (patch) | |
tree | 02f69178e2a0c32c5624179fe1bfb16a7adc541a | |
parent | e76e4778d172e2bf43026490256d33a8f5441393 (diff) | |
download | rails-611e1102d3bd46c4765bec7d57ca8d343c419e33.tar.gz rails-611e1102d3bd46c4765bec7d57ca8d343c419e33.tar.bz2 rails-611e1102d3bd46c4765bec7d57ca8d343c419e33.zip |
`target` in `CollectionAssociation` is always an array
So `target.is_a?(Array)` is meaningless, and just use `target.empty?`
instead of `target.blank?`.
-rw-r--r-- | activerecord/lib/active_record/associations/collection_association.rb | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/activerecord/lib/active_record/associations/collection_association.rb b/activerecord/lib/active_record/associations/collection_association.rb index 443ccaaa72..671c4c56df 100644 --- a/activerecord/lib/active_record/associations/collection_association.rb +++ b/activerecord/lib/active_record/associations/collection_association.rb @@ -214,7 +214,7 @@ module ActiveRecord target.size elsif !association_scope.group_values.empty? load_target.size - elsif !association_scope.distinct_value && target.is_a?(Array) + elsif !association_scope.distinct_value && !target.empty? unsaved_records = target.select(&:new_record?) unsaved_records.size + count_records else @@ -234,7 +234,7 @@ module ActiveRecord if loaded? size.zero? else - @target.blank? && !scope.exists? + target.empty? && !scope.exists? end end |