aboutsummaryrefslogtreecommitdiffstats
path: root/railties/guides/source/active_record_querying.textile
diff options
context:
space:
mode:
authorRyan Bigg <radarlistener@gmail.com>2010-12-23 16:39:10 +1000
committerRyan Bigg <radarlistener@gmail.com>2010-12-23 16:39:10 +1000
commit6271f3f16b5b9c6d60ba7d758d2b595be8074e00 (patch)
tree11bb87f7fb310fd5da79a05ec2716caab9bad19b /railties/guides/source/active_record_querying.textile
parent578f9711fdb42ca9fc4b8248c494afe755cd1c17 (diff)
downloadrails-6271f3f16b5b9c6d60ba7d758d2b595be8074e00.tar.gz
rails-6271f3f16b5b9c6d60ba7d758d2b595be8074e00.tar.bz2
rails-6271f3f16b5b9c6d60ba7d758d2b595be8074e00.zip
Query guide: Document "in" methods
Diffstat (limited to 'railties/guides/source/active_record_querying.textile')
-rw-r--r--railties/guides/source/active_record_querying.textile25
1 files changed, 25 insertions, 0 deletions
diff --git a/railties/guides/source/active_record_querying.textile b/railties/guides/source/active_record_querying.textile
index 1da12cbc9b..1bd9ec7972 100644
--- a/railties/guides/source/active_record_querying.textile
+++ b/railties/guides/source/active_record_querying.textile
@@ -363,6 +363,31 @@ The +eq_any+ method can be used to return objects of a relation that have the sp
Post.where(Post.arel_table[:comments_count].eq_any([1,2])
</ruby>
+h4. +in+
+
+To check if a value is within a given group of values, use the +in+ method:
+
+<ruby>
+ Post.where(Post.arel_table[:id].in([1,2,3]))
+</ruby>
+
+h4. +in_any+
+
+Check if a value is within any one of a group of values:
+
+<ruby>
+ Post.where(Post.arel_table[:id]).in_any([1,2,3], [4,5,6])
+</ruby>
+
+h4. +in_all+
+
+Check if a value is within all of the specified groups of values:
+
+<ruby>
+ Post.where(Post.arel_table[:id]).in_all([1,2,3], [1,4,6])
+</ruby>
+
+
h3. Ordering
To retrieve records from the database in a specific order, you can use the +order+ method.