Method: ActiveRecord::QueryMethods#or
- Defined in:
- activerecord/lib/active_record/relation/query_methods.rb
#or(other) ⇒ Object
Returns a new relation, which is the logical union of this relation and the one passed as an argument.
The two relations must be structurally compatible: they must be scoping the same model, and they must differ only by #where (if no #group has been defined) or #having (if a #group is present).
Post.where("id = 1").or(Post.where("author_id = 3"))
# SELECT `posts`.* FROM `posts` WHERE ((id = 1) OR (author_id = 3))
1167 1168 1169 1170 1171 1172 1173 1174 1175 1176 1177 |
# File 'activerecord/lib/active_record/relation/query_methods.rb', line 1167 def or(other) if other.is_a?(Relation) if @none other.spawn else spawn.or!(other) end else raise ArgumentError, "You have passed #{other.class.name} object to #or. Pass an ActiveRecord::Relation object instead." end end |