mirror of
https://github.com/github/rails.git
synced 2026-04-26 03:00:59 -04:00
Add Relation#all as an alias for to_a
This commit is contained in:
@@ -51,6 +51,8 @@ module ActiveRecord
|
||||
records
|
||||
end
|
||||
|
||||
alias all to_a
|
||||
|
||||
def first
|
||||
@relation = @relation.take(1)
|
||||
to_a.first
|
||||
|
||||
@@ -18,6 +18,12 @@ class RelationTest < ActiveRecord::TestCase
|
||||
assert_equal 4, topics.size
|
||||
end
|
||||
|
||||
def test_scoped_all
|
||||
topics = Topic.scoped.all
|
||||
assert_kind_of Array, topics
|
||||
assert_no_queries { assert_equal 4, topics.size }
|
||||
end
|
||||
|
||||
def test_finding_with_conditions
|
||||
assert_equal ["David"], Author.where(:name => 'David').map(&:name)
|
||||
assert_equal ['Mary'], Author.where(["name = ?", 'Mary']).map(&:name)
|
||||
|
||||
Reference in New Issue
Block a user