Reputation: 32130
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 Lorem 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
Upvotes: 0
Views: 499
Reputation: 1827
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)
Upvotes: 1