Colin Law wrote:
> On 27 August 2010 16:31, Marnen Laibow-Koser <[email protected]> 
> wrote:
>>> cars = UsedCar.find(:all, :order => :price)
>>> or to get just the cheapest
>>> cheapest_car = UsedCar.find(:all, :order => :price).first
>>
>> That will still retrieve all the records. �You want find :first, not
>> find :all.
> 
> Yes of course, my mistake.  Though in fact rails could be clever
> enough to work out from the statement find(:all).first that it only
> needs to fetch the first one.  

I have the impression that Arel may do things like that, but 2.x 
ActiveRecord does not.

> There is a limit to the magic it can
> sensibly perform however, and I was trying to push it beyond that
> limit.

:)

> 
> Colin

Best,
--
Marnen Laibow-Koser
http://www.marnen.org
[email protected]
-- 
Posted via http://www.ruby-forum.com/.

-- 
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Talk" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en.

Reply via email to