Guest User

Untitled

a guest
Feb 19th, 2018
75
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.02 KB | None | 0 0
  1. diff --git a/activerecord/lib/active_record/associations/association_collection.rb b/activerecord/lib/active_record/associations/association_collection.rb
  2. index a28be9e..9c44eb9 100644
  3. --- a/activerecord/lib/active_record/associations/association_collection.rb
  4. +++ b/activerecord/lib/active_record/associations/association_collection.rb
  5. @@ -206,7 +206,11 @@ module ActiveRecord
  6. end
  7.  
  8. def empty?
  9. - size.zero?
  10. + if loaded? || @reflection.options[:counter_sql]
  11. + size.zero?
  12. + else
  13. + !exists?({})
  14. + end
  15. end
  16.  
  17. def any?
  18. diff --git a/activerecord/lib/active_record/named_scope.rb b/activerecord/lib/active_record/named_scope.rb
  19. index d5a1c5f..ab842b4 100644
  20. --- a/activerecord/lib/active_record/named_scope.rb
  21. +++ b/activerecord/lib/active_record/named_scope.rb
  22. @@ -137,7 +137,7 @@ module ActiveRecord
  23. end
  24.  
  25. def empty?
  26. - @found ? @found.empty? : count.zero?
  27. + @found ? @found.empty? : !exists?({})
  28. end
  29.  
  30. def any?
Add Comment
Please, Sign In to add comment