0

I am trying to order my posts based on the created date ( newest to oldest ) so i do this :

@posts = Post.order('created_at DESC')

But the posts are not being affected by this. What can the problem be ?

the Tin Man
  • 158,662
  • 42
  • 215
  • 303
uklp
  • 551
  • 1
  • 6
  • 14

1 Answers1

0

Try something like this

@posts = Post.order(:created_at)

This way you order your data according to the created_at property

and if you want reversed order then

@posts = Post.order(:created_at).reverse
magmike
  • 473
  • 1
  • 5
  • 18
  • (http://sequel.jeremyevans.net/documentation.html) Check the documentation in the above link It is very helpful ;) – magmike Nov 20 '13 at 15:00