덕분에 내 실수를 지적 @Samuel하기 스코프)를 두 개의 스코프에 합치는 동안, self.scope(from,to).values[:joins]
과 같이했습니다.
'joined_scope'를 'where'절없이 구성한 두 개의 범위에서 값을 조인하고 싶었 기 때문에 별도로 'where'절을 추가 할 수있었습니다 ('AND'대신 'OR'을 사용하도록 변경됨)).
은 나를 위해,이과 같이, 결합 된 범위에 갔다 :
scope :joined_scope, -> (from, to) {
joins(self.first_scope(from,to).values[:joins])
.joins(self.other_scope(from,to).values[:joins])
.where(first_scope(from,to).ast.cores.last.wheres.inject{|ws, w| (ws &&= ws.and(w)) || w}
.or(other_scope(from,to).ast.cores.last.wheres.last))
}
을 희망 unscope 방법은 다음과 같이 작동하지 않습니다
사람에게하는 데 도움이 (더?)'User.complex_stuff. unscope (어디서 : : admin)'(http://api.rubyonrails.org/classes/ActiveRecord/QueryMethods.html#method-i-unscope 참조) – Samuel
무슨 뜻인지 알겠지만, 오늘 밤에 두 번 확인하고 대답. –