How do I write a UNION chain with ActiveRelation?
问题 I need to be able to chain an arbitrary number of sub-selects with UNION using ActiveRelation. I'm a little confused by the ARel implementation of this, since it seems to assume UNION is a binary operation. However: ( select_statement_a ) UNION ( select_statement_b ) UNION ( select_statement_c ) is valid SQL. Is this possible without doing nasty string-substitution? 回答1: You can do a bit better than what Adam Lassek has proposed though he is on the right track. I've just solved a similar