按升序导轨排序 [英] Sort in Ascending Order Rails

查看:106
本文介绍了按升序导轨排序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有这个模型

模型项

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

模型item_type

Model item_type

class Inventory::ItemType < ActiveRecord::Base
  belongs_to :item 
  attr_accessible :number
end

然后在控制器中说,我要基于项目名称以升序对类型(具有类ItemType的类型)进行排序.我该怎么办?

then let say in controller I want to sort types (which has class ItemType) in ascending order based on Item name. How do I do that?

例如,

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆