Skip to content
This repository
Browse code

Query guide: Document "in" methods

  • Loading branch information...
commit 6271f3f16b5b9c6d60ba7d758d2b595be8074e00 1 parent 578f971
Ryan Bigg radar authored

Showing 1 changed file with 25 additions and 0 deletions. Show diff stats Hide diff stats

  1. +25 0 railties/guides/source/active_record_querying.textile
25 railties/guides/source/active_record_querying.textile
Source Rendered
@@ -363,6 +363,31 @@ The +eq_any+ method can be used to return objects of a relation that have the sp
363 363 Post.where(Post.arel_table[:comments_count].eq_any([1,2])
364 364 </ruby>
365 365
  366 +h4. +in+
  367 +
  368 +To check if a value is within a given group of values, use the +in+ method:
  369 +
  370 +<ruby>
  371 + Post.where(Post.arel_table[:id].in([1,2,3]))
  372 +</ruby>
  373 +
  374 +h4. +in_any+
  375 +
  376 +Check if a value is within any one of a group of values:
  377 +
  378 +<ruby>
  379 + Post.where(Post.arel_table[:id]).in_any([1,2,3], [4,5,6])
  380 +</ruby>
  381 +
  382 +h4. +in_all+
  383 +
  384 +Check if a value is within all of the specified groups of values:
  385 +
  386 +<ruby>
  387 + Post.where(Post.arel_table[:id]).in_all([1,2,3], [1,4,6])
  388 +</ruby>
  389 +
  390 +
366 391 h3. Ordering
367 392
368 393 To retrieve records from the database in a specific order, you can use the +order+ method.

0 comments on commit 6271f3f

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