Skip to content
This repository
Browse code

Query guide: add or conditions

  • Loading branch information...
commit 890105f4f1ca471491c85f2aabd21d5a183ab189 1 parent 8713bb6
Ryan Bigg authored December 23, 2010
11  railties/guides/source/active_record_querying.textile
Source Rendered
@@ -457,6 +457,17 @@ Post.where(Post.arel_table[:comments_count].gteq_all([1,2]))
457 457
 
458 458
 This method's opposite is +lteq_all+.
459 459
 
  460
+h4. +or+
  461
+
  462
+Allows you to chain queries to get results matching either condition:
  463
+
  464
+<ruby>
  465
+title = Post.arel_table[:title]
  466
+Post.where(title.eq("Active").or(title.eq("Record")))
  467
+</ruby>
  468
+
  469
+Note that this method is called on the end of the +eq+ method here, rather than the +where+.
  470
+
460 471
 h3. Ordering
461 472
 
462 473
 To retrieve records from the database in a specific order, you can use the +order+ method.

0 notes on commit 890105f

Please sign in to comment.
Something went wrong with that request. Please try again.