rails/rails — pull request #16052 by matthewd (2014-07-04 15:28:09+00:00)
Title: Added #or to ActiveRecord::Relation

To complement the default *and* behaviour while building relations, allow two **very similar** relations to be combined with an *or*.

Post.where('id = 1').or(Post.where('id = 2'))
# => SELECT * FROM posts WHERE (id = 1) OR (id = 2)

Unlike previous attempts, we avoid any ambiguity about "how much" we're ORing by exclusively accepting a second relation -- thus, we're ORing whatever conditions differ between the two.

This is a much stricter variant of @gaelmuller's #9052; see also @oelmekki's #10891.

/cc @dhh @jeremy @tenderlove @rafaelfranca