2
我有一個ActiveRecord Annotation,有兩列:user_id和post_id,它們可以爲null。具有空user_id和post_id的註釋是適用於所有用戶的所有帖子的「全局」註釋。Rails 3 ActiveRecord where子句其中id設置或爲空
我想檢索與特定用戶的帖子和所有全局註釋相關的所有註釋。在MySQL中,SQL命令將是
select * from annotations where (user_id = 123 and post_id = 456) or (user_id is null and post_id is null)
在Rails 3中,將此代碼編寫爲Annotation.where子句的最佳方法是什麼?