Thank you Colin, Thank you Marnen for your reply,
@Colin: I was using seed because I had just finished populating the DB
and was just trying to write the program in the seed to make running the
program easier, nothing particular. Now I have written and called the
method somewhere else.
The cheapest car thing works. Something else has arisen! I have the code
on the office machine. will post it on weekdays!
Thanks a lot for your help.
Colin Law wrote:
> On 27 August 2010 16:31, Marnen Laibow-Koser <lists@ruby-forum.com>
> 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. There is a limit to the magic it can
> sensibly perform however, and I was trying to push it beyond that
> limit.
>
> Colin
--
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 rubyonrails-talk@googlegroups.com.
To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
No comments:
Post a Comment