diff options
-rw-r--r-- | activerecord/lib/active_record/relation.rb | 4 | ||||
-rw-r--r-- | activerecord/test/cases/relations_test.rb | 1 |
2 files changed, 4 insertions, 1 deletions
diff --git a/activerecord/lib/active_record/relation.rb b/activerecord/lib/active_record/relation.rb index 1c3a1dc53b..f89baa1a74 100644 --- a/activerecord/lib/active_record/relation.rb +++ b/activerecord/lib/active_record/relation.rb @@ -13,6 +13,10 @@ module ActiveRecord @klass.find_by_sql(@relation.to_sql) end + def each(&block) + to_a.each(&block) + end + def first @relation = @relation.take(1) to_a.first diff --git a/activerecord/test/cases/relations_test.rb b/activerecord/test/cases/relations_test.rb index c095d9455e..ac3a80afb7 100644 --- a/activerecord/test/cases/relations_test.rb +++ b/activerecord/test/cases/relations_test.rb @@ -73,6 +73,5 @@ class RealtionTest < ActiveRecord::TestCase ).to_a assert_equal 1, person_with_reader_and_post.size end - end |