From b0b37942d729b6bdcd2e3178eda7fa1de203b3d0 Mon Sep 17 00:00:00 2001 From: Matthew Draper Date: Mon, 23 Jun 2014 11:42:46 +0800 Subject: Added #or to ActiveRecord::Relation Post.where('id = 1').or(Post.where('id = 2')) # => SELECT * FROM posts WHERE (id = 1) OR (id = 2) [Matthew Draper & Gael Muller] --- activerecord/lib/active_record/null_relation.rb | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'activerecord/lib/active_record/null_relation.rb') diff --git a/activerecord/lib/active_record/null_relation.rb b/activerecord/lib/active_record/null_relation.rb index b406da14dc..802adca908 100644 --- a/activerecord/lib/active_record/null_relation.rb +++ b/activerecord/lib/active_record/null_relation.rb @@ -75,5 +75,13 @@ module ActiveRecord def exists?(_id = false) false end + + def or(other) + if other.is_a?(NullRelation) + super + else + other.or(self) + end + end end end -- cgit v1.2.3