我希望有像
这样的方法Shift.by_quarter(1) => each shift in first quarter of current year
现在我按日期选择四分之一班次
Shift
scope :by_quarter, lambda{|date|
where starts_at: date.beginning_of_quarter..date.end_of_quarter}
答案 0 :(得分:4)
我的解决方案:
scope :by_quarter, lambda{|quarter|
date = Date.new(Date.today.year, quarter * 3)
where starts_at: date.beginning_of_quarter..date.end_of_quarter }