I have an integer column “level”. I want to order on level by doing this in the controller:
@leagues = League.all.order('level')
This results in 1, 10, 2, 3 as results, where I would expect 1, 2, 3, 10 as results.
How can I solve this?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Sounds like you created the column as a string in the DB … if it was a int, you’d get 1, 2, 3, 10 … at least with MySQL!