1
我想將我的類方法重寫爲作用域。如何將rails group_by類方法重寫爲作用域
class Team
def self.grouped
self.all.group_by { |e| e.type }.map { |k, v| { k => v.group_by { |e| e.sub_type } } }
end
end
我該如何寫作範圍?
class Team
# scope :grouped ??
end