ActiveRecord chaining multiple union with Arel

It seems chain uinon with union is possible with newer versions of Arel. But i currently stucked with 3.0.2 so this is what i come up with:

beer = Beer.arel_table
union1 = Beer.where(name: "Oberon").union(Beer.where(name: "Two Hearted")) 
table1 = Beer.select("two_beers.*").from(beer.create_table_alias(union1, :two_beers).to_sql)

union2 = table1.union(Beer.where(name: "Distilled"))
table2 = Beer.from(beer.create_table_alias(union2, :beers).to_sql)

The generated SQL is far from being nice but for me works.

Bonyiii About 10 years ago