Colin Law wrote:
> On 27 August 2010 15:19, Dakshata Gulkhobare <[email protected]> 
> wrote:
>> car_price = UsedCar.find(:all, :order => 'price DESC' )
> 
> That will give you them all in descending price order so the first one
> will be the most expensive.  You could have called it cars rather than
> car_price to indicate that it is an array (or similar) of Cars.  If
> you want them in price increasing you can say
> 
> 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.

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