我有以下两个模型:
class Shelf < ActiveRecord::Model
has_many :wines
def self.order_by_oldest_bottle_of_wine
#TODO: order by the oldest wine bottle...
end
end
class Wine < ActiveRecord::Model
belongs_to :shelf
attr_accessible :produce_date
end
在货架模型中,我想按货架上最旧的酒瓶订购货架(即货架上最旧的酒瓶在前),但不能 100% 确定实施。
非常感谢,