diff options
author | Emilio Tagua <miloops@gmail.com> | 2009-08-03 14:15:47 -0300 |
---|---|---|
committer | Emilio Tagua <miloops@gmail.com> | 2009-08-03 14:15:47 -0300 |
commit | f8eb4434d61fc1585c9b88dbb2d9159ea1f5b2fa (patch) | |
tree | ef47868b0b57fc4fa9351c9992cab868c572058f /activerecord | |
parent | 31c83534d61cad2203ae57087442caedb4dbf22a (diff) | |
download | rails-f8eb4434d61fc1585c9b88dbb2d9159ea1f5b2fa.tar.gz rails-f8eb4434d61fc1585c9b88dbb2d9159ea1f5b2fa.tar.bz2 rails-f8eb4434d61fc1585c9b88dbb2d9159ea1f5b2fa.zip |
Added collection iteration to AR::Relation.
Diffstat (limited to 'activerecord')
-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 |