0

I have a model Country and it has a string attribute 'name_en' which value can be for example "England" or "[India]". How can I order properly by this attribute?

2
  • give an example of what you have tried and why it does not work...that would be helpful in knowing what the problem is. Commented Oct 25, 2013 at 9:12
  • define what "properly" means to you. Do you want to ignore the square brackets around 'India' and have it come after 'England' alphabetically? Commented Oct 25, 2013 at 10:43

1 Answer 1

1

You really need to read the documentation before you can go any far with rails. What you need (and a lot more) is explained here:

And to order by name you should:

Country.order('name_en').all
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.