Query guide: add or conditions

This commit is contained in:
Ryan Bigg 2010-12-23 22:15:08 +10:00
parent 8713bb6ab8
commit 890105f4f1
1 changed files with 11 additions and 0 deletions

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.