在Rails 3.1 RC6,给出
class Animal < ActiveRecord::Base default_scope where(legs: 4) end
以下不能按预期方式工作:
class Man < Animal default_scope unscoped.where(legs: 2) end
SELECT * FROM animals WHERE legs = 4 AND legs = 2
如何完全覆盖父类的默认范围?
我也尝试过以下工作:
default_scope{ unscoped.where legs: 2 } default_scope with_exclusive_scope{ legs: 2 }