diff options
author | Ryan Bigg <radarlistener@gmail.com> | 2010-12-24 10:47:38 +1000 |
---|---|---|
committer | Ryan Bigg <radarlistener@gmail.com> | 2010-12-24 10:47:38 +1000 |
commit | d1e95e12b4d56fac58ee680fd2d8d5cdac57b2ac (patch) | |
tree | 51352033aedbb943f65dafa87bbc0e598c4221d1 /railties/guides/source | |
parent | e4314e7d3fd93c5ed1eda1cf52ed38cdc2543d25 (diff) | |
download | rails-d1e95e12b4d56fac58ee680fd2d8d5cdac57b2ac.tar.gz rails-d1e95e12b4d56fac58ee680fd2d8d5cdac57b2ac.tar.bz2 rails-d1e95e12b4d56fac58ee680fd2d8d5cdac57b2ac.zip |
Revert "Query guide: arel_table, eq and eq_any" along with other commits that added documentation involving the arel_table method
This reverts commit 578f9711fdb42ca9fc4b8248c494afe755cd1c17.
Conflicts:
railties/guides/source/active_record_querying.textile
Diffstat (limited to 'railties/guides/source')
-rw-r--r-- | railties/guides/source/active_record_querying.textile | 131 |
1 files changed, 0 insertions, 131 deletions
diff --git a/railties/guides/source/active_record_querying.textile b/railties/guides/source/active_record_querying.textile index a45624809e..61d8205278 100644 --- a/railties/guides/source/active_record_querying.textile +++ b/railties/guides/source/active_record_querying.textile @@ -337,137 +337,6 @@ This code will generate SQL like this: SELECT * FROM clients WHERE (clients.orders_count IN (1,3,5)) </sql> -h4. +arel_table+ - -The +arel_table+ method is used in the following sections to gain access to more advanced functionality of the Active Relation building language. You may see examples such as this: - -<ruby> -Post.where(Post.arel_table[:comments_count].eq(5))) -</ruby> - -Don't be alarmed! This method returns an +Arel::Table+ object which provides methods for accessing fields and building queries, as you'll see in the following sections. - -h4. +eq+ - -The +eq+ method can be used to check if a field is a specific value: - -<ruby> -Post.where(Post.arel_table[:comments_count].eq(5)) -</ruby> - -This method's opposite is +not_eq+. - -h4. +eq_any+ - -Checks if the specified field matches any of the given values. - -<ruby> -Post.where(Post.arel_table[:comments_count].eq_any([1,2]) -</ruby> - -This method's opposite is +not_eq_any+. - -h4. +in+ - -To check if a field is within a given group of values, use the +in+ method: - -<ruby> -Post.where(Post.arel_table[:id].in([1,2,3])) -</ruby> - -This method's opposite is +not_in+. - -h4. +in_any+ - -Check if a field 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> - -This method's opposite is +not_in_any+. - -h4. +in_all+ - -Check if a field 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> - -This method's opposite is +not_in_all+. - -h4. +matches+ - -Match a specific field with a given value. Use +%+ for wildcard searching. - -<ruby> -Post.where(Post.arel_table[:author].matches("Ryan%")) -</ruby> - -This method's opposite is +does_not_match+. - -h4. +matches_any+ - -Match a specific field with any given value. Use +%+ for wildcard searching. - -<ruby> -Post.where(Post.arel_table[:author].matches_any(["Ryan%", "Yehuda%"])) -</ruby> - -This method's opposite is +does_not_match_any+ - -h4. +matches_all+ - -Match a specific field with all given values. Use +%+ for wild card searching. - -<ruby> -Post.where(Post.arel_table[:author].matches_all(["Ryan%", "%Bigg"])) -</ruby> - -This method's opposite is +does_not_match_all+. - -h4. +gteq+ - -Check for a field greater than or equal to a specific value. - -<ruby> -Post.where(Post.arel_table[:comments_count].gteq(1)) -</ruby> - -This method's opposite is +lteq+. - -h4. +gteq_any+ - -Check for a field greater than or equal to any of the given values. - -<ruby> -Post.where(Post.arel_table[:comments_count].gteq_any([1,2])) -</ruby> - -This method's opposite is +lteq_any+. - -h4. +gteq_all+ - -Check for a field greater than or equal to all of the given values. - -<ruby> -Post.where(Post.arel_table[:comments_count].gteq_all([1,2])) -</ruby> - -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. |