我们过去在 rails 3.0 中使用的非常方便的东西是范围的可重用性。让我们看一个例子。
class Wheel < AR::B
belongs_to :car
scope :deflated, where (:deflated => true)
end
class Car < AR::B
has_many :wheels
scope :out_of_service, joins(:wheels) & Wheel.deflated
end
但它似乎在 3.1 中不再起作用,你知道是否有新的方法可以做到这一点吗?谢谢