我有一個名為 的時隙時間實體串列slots,其中包含一個開始時間列。
我想對這些插槽進行分組,start_time.to_date但我找不到將這些方法鏈接在一起的語法。
我目前通過運行以下代碼得到的錯誤是undefined method to_date for :start_time:Symbol
slots.group_by(&:start_time.to_date)
uj5u.com熱心網友回復:
您將需要定義 group_by 塊
slots.group_by {|slot| slot.start_time.to_date }
轉載請註明出處,本文鏈接:https://www.uj5u.com/caozuo/472670.html
