Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我有一个具有属性 date:DateTime 的模型事件
我只想按 Date 对 Event 进行分组,如果我使用 group_by(&:date) 然后它按 DateTime 分组,我无法更改 Model 属性,因为我还需要 Time 稍后显示。
Event.group_by(&:date_col) def group_by_criteria date_col.to_date.to_s(:db) end Event.group_by(&:group_by_criteria)
这将仅按日期分组。