diff options
author | Ryan Bigg <radarlistener@gmail.com> | 2010-12-23 22:15:08 +1000 |
---|---|---|
committer | Ryan Bigg <radarlistener@gmail.com> | 2010-12-23 22:15:08 +1000 |
commit | 890105f4f1ca471491c85f2aabd21d5a183ab189 (patch) | |
tree | 71bd6ff04b438fec6d0fa1bd7521c22093c4c5df /railties/guides | |
parent | 8713bb6ab8ff5acf60872b0b8f0bffd13a0aa1ca (diff) | |
download | rails-890105f4f1ca471491c85f2aabd21d5a183ab189.tar.gz rails-890105f4f1ca471491c85f2aabd21d5a183ab189.tar.bz2 rails-890105f4f1ca471491c85f2aabd21d5a183ab189.zip |
Query guide: add or conditions
Diffstat (limited to 'railties/guides')
-rw-r--r-- | railties/guides/source/active_record_querying.textile | 11 |
1 files changed, 11 insertions, 0 deletions
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: + +<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. |