Sort in Ascending Order Rails

后端 未结 5 1607
我寻月下人不归
我寻月下人不归 2021-02-02 08:46

Hi I have this model

Model item

class Inventory::Item < ActiveRecord::Base
  has_many :types, :class_name => \"ItemType\"
  attr_accessible :na         


        
5条回答
  •  失恋的感觉
    2021-02-02 09:18

    To retrieve records from the database in a specific order, you can use the order method:

    Item.order(:name)
    

    by default this sorts ascending.

提交回复
热议问题