# :order question

**URL:** <https://www.ruby-forum.com/t/order-question/112277>\
**Category:** Rails\
**Created:** [August 17, 2007, 12:37am UTC](https://www.ruby-forum.com/t/order-question/112277 "2007-08-17T00:37:28Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Brien](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/a6a055/32.png) [@Brien](https://www.ruby-forum.com/u/Brien)\
**Post date:** [August 17, 2007, 12:37am UTC](https://www.ruby-forum.com/t/order-question/112277/1 "2007-08-17T00:37:28Z")

</div>

I’m new to rails, so excuse me if this is a silly/simple question - It  
appears that rails is doing the annoying way of ordering items, with  
10 - 19 following 1, 20-29 following 2, etcetera.

Does anyone know of a way to make it logically order id’s?

---

<div class="post-metadata">

**Author:** ![Brien](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/a6a055/32.png) [@Brien](https://www.ruby-forum.com/u/Brien)\
**Post date:** [August 17, 2007, 12:58am UTC](https://www.ruby-forum.com/t/order-question/112277/2 "2007-08-17T00:58:03Z")

</div>

Brien wrote:

> I’m new to rails, so excuse me if this is a silly/simple question - It  
> appears that rails is doing the annoying way of ordering items, with  
> 10 - 19 following 1, 20-29 following 2, etcetera.
> 
> Does anyone know of a way to make it logically order id’s?

The most likely reason for this is that you made the id column a string  
in the database rather that making it an INT.  
If this is not the case or you don’t understand please post the  
migration/sql you used to create the table your selecting from. So we  
can help further.

Keynan

---

<div class="post-metadata">

**Author:** ![Brien](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/a6a055/32.png) [@Brien](https://www.ruby-forum.com/u/Brien)\
**Post date:** [August 17, 2007, 1:29am UTC](https://www.ruby-forum.com/t/order-question/112277/3 "2007-08-17T01:29:35Z")

</div>

class CreatePosts \< ActiveRecord::Migration  
def self.up  
create\_table :posts do |t|  
end  
end

def self.down  
drop\_table :posts  
end  
end

I’ve been using CocoaMySQL for managing the tables directly, as well.

I’m trying to call posts.id with classic pagination, namely

```
@post_pages, @posts = paginate :posts, :order => 'id', :per_page

```

=\> 10

On Aug 16, 3:58 pm, Keynan P. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)
