답변

12

where 문을 연결하거나 where 호출에 여러 조건을 포함 할 수 있습니다.

Model.where(condition_a: :a, condition_b: :b).all 

나 또한

Model.where(condition_a: :a).where(condition_b: :b).all 
+0

고맙습니다. D – hyperrjas

+0

조건에 따라 두 번째'where'는 첫 번째'where'에서 키를 겹쳐 쓸 수 있습니다. 즉'where (foo : 'a'). 여기서 (foo : 'b')'는 그렇지 않습니다. 'where (foo : 'a').와 (foo : 'b')'와 동일합니다. – Stefan

2

, 당신은 체인 가지 예를 들어 .and(other_thing:'value')

사용 할 수 Model.where(awesome:true).and(other_thing:true) 어떤 조건

관련 문제