을 기본 상위 클래스에서 깰 수액티브 STI : 어떻게 '범위 주어진 레일 3.1 RC6에
class Animal < ActiveRecord::Base
default_scope where(legs: 4)
end
예상대로 작동하지 않습니다 다음
class Man < Animal
default_scope unscoped.where(legs: 2)
end
결과 SQL 문을 다음과 같이 보입니다 :
SELECT * FROM animals WHERE legs = 4 AND legs = 2
부모 클래스의 기본 범위를 완전히 무시하려면 어떻게해야합니까?
default_scope{ unscoped.where legs: 2 }
default_scope with_exclusive_scope{ legs: 2 }
http://m.onkey.org/default-scopes-and-inheritance-to-the-rescue 도움이 레일즈 3.0에서 작동하는 것 같습니다 : self.default_scoping = [] – jemminger