【发布时间】:2019-02-15 15:30:12
【问题描述】:
假设有一个预订系统来预订某个活动的时间段。
我有一个事件模型和一个 time_slot 模型。每个事件都有man time_slots,每个slot都属于一个事件
class Event < ActiveRecord::Base
has_many :time_slot
end
class TimeSlot < ActiveRecord::Base
belongs_to :event
end
当我做一个Event.find(some_id)
如何根据模型上的字段对返回的时隙进行排序,例如“slot_time”
【问题讨论】:
-
善待你的程序员,使用正确的复数
has_many :time_slots。
标签: ruby-on-rails ruby ruby-on-rails-5 rails-activerecord