Combine two ActiveRecord::Relation objects

Suppose I have the following two objects:

first_name_relation = User.where(:first_name => 'Tobias') # ActiveRecord::Relation
last_name_relation  = User.where(:last_name  => 'Fünke') # ActiveRecord::Relation

is it possible to combine the two relations to produce one ActiveRecord::Relation object containing both conditions?

Note: I’m aware that I can chain the wheres to get this behavior, what I’m really interested in is the case where I have two separate ActiveRecord::Relation objects.

10 Answers

Leave a Comment