1
0
Fork 0
mirror of https://github.com/rails/rails.git synced 2022-11-09 12:12:34 -05:00

Query guide: add or conditions

This commit is contained in:
Ryan Bigg 2010-12-23 22:15:08 +10:00
parent 8713bb6ab8
commit 890105f4f1

View file

@ -457,6 +457,17 @@ Post.where(Post.arel_table[:comments_count].gteq_all([1,2]))
This method's opposite is +lteq_all+.
h4. +or+
Allows you to chain queries to get results matching either condition:
<ruby>
title = Post.arel_table[:title]
Post.where(title.eq("Active").or(title.eq("Record")))
</ruby>
Note that this method is called on the end of the +eq+ method here, rather than the +where+.
h3. Ordering
To retrieve records from the database in a specific order, you can use the +order+ method.