user_id와 post_id라는 두 개의 열이있는 ActiveRecord, Annotation이 있는데, null 일 수 있습니다. null user_id 및 post_id가있는 주석은 모든 사용자의 모든 게시물에 적용되는 "전역"주석입니다.레일 3 ActiveRecord where 절이 id가 설정되거나 null 인 곳
특정 사용자의 게시물 및 모든 글로벌 주석과 관련된 모든 주석을 검색하고 싶습니다. MySQL의에서 SQL 명령은 레일 3에서
select * from annotations where (user_id = 123 and post_id = 456) or (user_id is null and post_id is null)
될하는 Annotation.where 조항으로이 코드에 가장 좋은 방법은 무엇입니까?