rails/rails — pull request #12810 by eljojo (2013-11-08 16:56:29+00:00)
Title: Using #count instead of delegating to array for #one? in ActiveRecord::Delegation::Relation

I noticed that whenever I send ``#one?`` to an ActiveRecord Relation, it delegates the message to ``#to_a`` which is not really optimal.

```
>> Product.all.class
=> ActiveRecord::Relation::ActiveRecord_Relation_Product
>> Product.all.one?
Product Load (118.6ms) SELECT "products".* FROM "products"
=> false
>> Product.all.any?
(1.0ms) SELECT COUNT(*) FROM "products"
=> true
>> Product.all.count == 1
(1.2ms) SELECT COUNT(*) FROM "products"
=> false
>>
```

If you guys think this is ok I think I could write some tests.
I just noticed that this should probably also go in ActiveRecord::Associations::CollectionAssociation