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子句的最佳方法是什么?