Skip to content

Instantly share code, notes, and snippets.

@lasershow
Created January 29, 2016 14:14
Show Gist options
  • Save lasershow/76a6ab0fbbc6d0dfdbce to your computer and use it in GitHub Desktop.
Save lasershow/76a6ab0fbbc6d0dfdbce to your computer and use it in GitHub Desktop.
あれっ?降順ってASC?DESC?そんな時は、reverse_orderを使ってみましょう! ref: http://qiita.com/lasershow/items/5bcefcbd6ae86a5ff202
pry(main)> Comment.all
=>
[#<
id: 1,
content: "あ">,
#<
id: 2,
content: "い">,
#<
id: 3,
content: "う">
]
Comment.order(id: "DESC")
Comment.order("id DESC")
Comment.all.order(id: "DESC")
Comment.all.order("id DESC")
Comment.order(id: "ASC")
Comment.order("id ASC")
Comment.all.order(id: "ASC")
Comment.all.order("id ASC")
Comment.all.reverse_order
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment