diff options
-rw-r--r-- | activerecord/lib/active_record/relation.rb | 2 | ||||
-rw-r--r-- | activerecord/test/cases/relations_test.rb | 6 |
2 files changed, 7 insertions, 1 deletions
diff --git a/activerecord/lib/active_record/relation.rb b/activerecord/lib/active_record/relation.rb index fa517aba38..52d66dc20a 100644 --- a/activerecord/lib/active_record/relation.rb +++ b/activerecord/lib/active_record/relation.rb @@ -250,7 +250,7 @@ module ActiveRecord if block_given? to_a.many? { |*block_args| yield(*block_args) } else - size > 1 + @relation.send(:taken).present? ? to_a.many? : size > 1 end end diff --git a/activerecord/test/cases/relations_test.rb b/activerecord/test/cases/relations_test.rb index 5d6f9ad430..6605c8bf34 100644 --- a/activerecord/test/cases/relations_test.rb +++ b/activerecord/test/cases/relations_test.rb @@ -471,4 +471,10 @@ class RelationTest < ActiveRecord::TestCase assert posts.loaded? end + def test_many_with_limits + posts = Post.scoped + + assert posts.many? + assert ! posts.limit(1).many? + end end |