From 890105f4f1ca471491c85f2aabd21d5a183ab189 Mon Sep 17 00:00:00 2001 From: Ryan Bigg Date: Thu, 23 Dec 2010 22:15:08 +1000 Subject: Query guide: add or conditions --- railties/guides/source/active_record_querying.textile | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/railties/guides/source/active_record_querying.textile b/railties/guides/source/active_record_querying.textile index 8eb28ec953..b4db365a09 100644 --- a/railties/guides/source/active_record_querying.textile +++ b/railties/guides/source/active_record_querying.textile @@ -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: + + +title = Post.arel_table[:title] +Post.where(title.eq("Active").or(title.eq("Record"))) + + +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. -- cgit v1.2.3