# Put the list of posts in descending order

**URL:** <https://www.ruby-forum.com/t/put-the-list-of-posts-in-descending-order/152459>\
**Category:** Rails\
**Created:** [November 4, 2008, 7:13am UTC](https://www.ruby-forum.com/t/put-the-list-of-posts-in-descending-order/152459 "2008-11-04T07:13:33Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Ishara\_G](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/i/e68b1a/32.png) [@Ishara\_G](https://www.ruby-forum.com/u/Ishara_G)\
**Post date:** [November 4, 2008, 7:13am UTC](https://www.ruby-forum.com/t/put-the-list-of-posts-in-descending-order/152459/1 "2008-11-04T07:13:33Z")

</div>

hi,i have a table called blogs which include  
t.column :user\_id, :integer  
t.column :post\_id, :integer  
t.column:title, :string  
t.column:body, :string

and i have a seperate form to fill the title and post field,i can  
display the title and body in a page.but the records are displayed in  
the ascending order,that means the last i last i entered is displayed  
first  
…but i want to display it in descending order,that mean the newly  
entered  
record should display at the top of the page,please can anyone send me  
the code to do this

---

<div class="post-metadata">

**Author:** ![Ishara\_G](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/i/e68b1a/32.png) [@Ishara\_G](https://www.ruby-forum.com/u/Ishara_G)\
**Post date:** [November 4, 2008, 3:22pm UTC](https://www.ruby-forum.com/t/put-the-list-of-posts-in-descending-order/152459/2 "2008-11-04T15:22:42Z")

</div>

thankx…il try

2008/11/4 Thorsten MÃ¼ller [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)

---

<div class="post-metadata">

**Author:** ![Ishara\_G](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/i/e68b1a/32.png) [@Ishara\_G](https://www.ruby-forum.com/u/Ishara_G)\
**Post date:** [November 4, 2008, 11:18am UTC](https://www.ruby-forum.com/t/put-the-list-of-posts-in-descending-order/152459/3 "2008-11-04T11:18:20Z")

</div>

> the last i last i entered is displayed first  
> …but i want to display it in descending order,that mean the newly entered  
> record should display at the top of the page

Isn’t that the same? Last/newly entered display first?

anyway, in the examples replace DESC by ASC to revert order

if your model has a created\_at column:  
@blogs = Blog.find(:all, :order =\> “created\_at DESC”)

if you don’t have the created\_at col (you should), sort by id:  
@blogs = Blog.find(:all, :order =\> “id DESC”)
