我已经成功使用了以下宝石:Arel顶部的squeel,因此您不必弄乱它。因此,为了生成查询,您可以在Squeel中执行以下操作:
@articles = Article. where{ ( user_id.eq(1) | status.eq('published') ) | ( user_id.in([10, 11, 12, '<...>']) & status.eq('temp') )}# since this is an ActiveRecord::Relation we can play around with it@articles = @articles.select{ [ user_id, status ] }# and you can also inspect your SQL to see what is going to come outputs @articles.to_sql查询越复杂,得到的宝石就越多。



