Alphabetical order Ruby on Rails

2

I need to put my category in alphabetical order:

@posts_categories = Admin::PostCategory.all
    
asked by anonymous 19.01.2016 / 17:25

1 answer

1

Sorting can be done this way:

@posts_categories = Admin::PostCategory.order(name: :asc)

That's if the poss_categories table has the "name" field. If not, just replace with the name of the field to use as sorting criteria.

The asc says that the sort will be done ascending (A-Z or 0 - 10 ...)

To learn more about it, visit: link

    
19.01.2016 / 18:03