Sorting Strings in Rails using Order
I Have a model "Msg" and it has a content as a string and a username as a string as well
at the moment all my Msgs have their content Lor开发者_运维知识库em Ipsumed and I'd like to sort them out
I'm trying to do something like
Msg.all(:order => "content DESC")
but it will not sort the strings for me..
Is there anyway to sort the strings in one line to get all of the Msgs (or the actual strings)
Thanks
Im not sure to understand the question.
Msg.all(:order => "content DESC")
retrieves all messages ordered by its content. Consequently, mapping its content attributes returns all the strings properly sorted
Msg.all(:order => "content DESC").map(&:content)
精彩评论