# Order by not working on all

**URL:** <https://www.ruby-forum.com/t/order-by-not-working-on-all/192406>\
**Category:** Rails\
**Created:** [July 29, 2010, 6:15pm UTC](https://www.ruby-forum.com/t/order-by-not-working-on-all/192406 "2010-07-29T18:15:11Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![markh](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/7993a0/32.png) [@markh](https://www.ruby-forum.com/u/markh)\
**Post date:** [July 29, 2010, 6:15pm UTC](https://www.ruby-forum.com/t/order-by-not-working-on-all/192406/1 "2010-07-29T18:15:11Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![markh](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/7993a0/32.png) [@markh](https://www.ruby-forum.com/u/markh)\
**Post date:** [July 29, 2010, 6:19pm UTC](https://www.ruby-forum.com/t/order-by-not-working-on-all/192406/2 "2010-07-29T18:19:43Z")

</div>

On Thu, Jul 29, 2010 at 11:15 AM, Mark H. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)  
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](http://destiney.com) | [gregdonald.com](http://gregdonald.com)

---

<div class="post-metadata">

**Author:** ![markh](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/7993a0/32.png) [@markh](https://www.ruby-forum.com/u/markh)\
**Post date:** [July 29, 2010, 6:34pm UTC](https://www.ruby-forum.com/t/order-by-not-working-on-all/192406/3 "2010-07-29T18:34:59Z")

</div>

Greg D. wrote:

> ## Car.order(“make”).all
> 
> Greg D.  
> [destiney.com](http://destiney.com) | [gregdonald.com](http://gregdonald.com)

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

Mark H.

---

<div class="post-metadata">

**Author:** ![markh](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/7993a0/32.png) [@markh](https://www.ruby-forum.com/u/markh)\
**Post date:** [July 29, 2010, 9:00pm UTC](https://www.ruby-forum.com/t/order-by-not-working-on-all/192406/4 "2010-07-29T21:00:38Z")

</div>

Mark H. wrote:

> Greg D. wrote:
> 
> > ## Car.order(“make”).all
> > 
> > Greg D.  
> > [destiney.com](http://destiney.com) | [gregdonald.com](http://gregdonald.com)
> 
> Thank you! 🙂 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

---

<div class="post-metadata">

**Author:** ![markh](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/7993a0/32.png) [@markh](https://www.ruby-forum.com/u/markh)\
**Post date:** [July 30, 2010, 5:35am UTC](https://www.ruby-forum.com/t/order-by-not-working-on-all/192406/5 "2010-07-30T05:35:44Z")

</div>

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
