Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Added collection iteration to AR::Relation.

  • Loading branch information...
commit f8eb4434d61fc1585c9b88dbb2d9159ea1f5b2fa 1 parent 31c8353
@miloops miloops authored
View
4 activerecord/lib/active_record/relation.rb
@@ -13,6 +13,10 @@ def to_a
@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
View
1  activerecord/test/cases/relations_test.rb
@@ -73,6 +73,5 @@ def test_joins_with_string_array
).to_a
assert_equal 1, person_with_reader_and_post.size
end
-
end
Please sign in to comment.
Something went wrong with that request. Please try again.