active-relation

ActiveRecord Query Union

那年仲夏 提交于 2019-11-26 03:54:10
问题 I\'ve written a couple of complex queries (at least to me) with Ruby on Rail\'s query interface: watched_news_posts = Post.joins(:news => :watched).where(:watched => {:user_id => id}) watched_topic_posts = Post.joins(:post_topic_relationships => {:topic => :watched}).where(:watched => {:user_id => id}) Both of these queries work fine by themselves. Both return Post objects. I would like to combine these posts into a single ActiveRelation. Since there could be hundreds of thousands of posts at