Created
January 29, 2016 14:14
-
-
Save lasershow/76a6ab0fbbc6d0dfdbce to your computer and use it in GitHub Desktop.
あれっ?降順ってASC?DESC?そんな時は、reverse_orderを使ってみましょう! ref: http://qiita.com/lasershow/items/5bcefcbd6ae86a5ff202
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
pry(main)> Comment.all | |
=> | |
[#< | |
id: 1, | |
content: "あ">, | |
#< | |
id: 2, | |
content: "い">, | |
#< | |
id: 3, | |
content: "う"> | |
] | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Comment.order(id: "DESC") | |
Comment.order("id DESC") | |
Comment.all.order(id: "DESC") | |
Comment.all.order("id DESC") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Comment.order(id: "ASC") | |
Comment.order("id ASC") | |
Comment.all.order(id: "ASC") | |
Comment.all.order("id ASC") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Comment.all.reverse_order |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment