Order by not working on all

Car.all.order(“make”) generates an error like “undefined method `order’
for #Array:0x7fd314476e38

Is this a bug? It seems that it should work. Rails 3.0.0rc.

On Thu, Jul 29, 2010 at 11:15 AM, Mark H. [email protected]
wrote:

Car.all.order(“make”) generates an error like “undefined method `order’
for #Array:0x7fd314476e38

Is this a bug? It seems that it should work. Rails 3.0.0rc.

Car.order(“make”).all


Greg D.
destiney.com | gregdonald.com

Greg D. wrote:

Car.order(“make”).all

Greg D.
destiney.com | gregdonald.com

Thank you! :slight_smile: It seems odd considering that Car.where(blah
blah).order(‘make’) works.

Mark H.

Mark H. wrote:

Greg D. wrote:

Car.order(“make”).all

Greg D.
destiney.com | gregdonald.com

Thank you! :slight_smile: It seems odd considering that Car.where(blah
blah).order(‘make’) works.

If I understand it right you don’t need the “all” part at all:

Car.order(“make”)

The way I understand it “all” is a special method designed to get “all”
records in a similar way as all was in the old syntax.

In other words:

Car.find(:all, :order => ‘make’) not the same as Car.all

Robert W. wrote:

Car.order(“make”)

The way I understand it “all” is a special method designed to get “all”
records in a similar way as all was in the old syntax.

In other words:

Car.find(:all, :order => ‘make’) not the same as Car.all

Ah yes, that would take advantage of the lazy loading I think. And the
syntax makes more sense. Thanks.

Mark

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs