Module: PolymorphicJoin::ClassMethods
- Defined in:
- lib/polymorphic_join.rb
Instance Method Summary collapse
Instance Method Details
#polymorphic_union_scope(types, *scopes) ⇒ Object
13 14 15 16 17 18 19 20 21 22 23 24 25 |
# File 'lib/polymorphic_join.rb', line 13 def polymorphic_union_scope(types, *scopes) union = scopes[0] t2 = arel_table if scopes.length > 1 (1..(scopes.length - 1)).each do |i| union = union.union(scopes[i]) end end t1 = arel_table.create_table_alias(union, types) from(t2.create_join(t1, t2.create_on(t1[:id].eq(t2[:id])))) end |