diff options
author | Vijay Dev <vijaydev.cse@gmail.com> | 2012-04-29 15:50:31 +0530 |
---|---|---|
committer | Vijay Dev <vijaydev.cse@gmail.com> | 2012-04-29 15:53:16 +0530 |
commit | 6bea191a750db805aefa82339074fe61637e8fb1 (patch) | |
tree | 1bbc9b3a2441533e31fe3488451959d5d134af43 /guides/source | |
parent | 0b019cc3b821eb362ef3f75f4bc16727c1f23fa6 (diff) | |
download | rails-6bea191a750db805aefa82339074fe61637e8fb1.tar.gz rails-6bea191a750db805aefa82339074fe61637e8fb1.tar.bz2 rails-6bea191a750db805aefa82339074fe61637e8fb1.zip |
Removed unclear doc in AR querying guide [ci skip]
The range example used in array conditions is unclear and talks about
the old 'conditions' option. Closes #4943.
Diffstat (limited to 'guides/source')
-rw-r--r-- | guides/source/active_record_querying.textile | 16 |
1 files changed, 0 insertions, 16 deletions
diff --git a/guides/source/active_record_querying.textile b/guides/source/active_record_querying.textile index 98937266ba..902ceeb78b 100644 --- a/guides/source/active_record_querying.textile +++ b/guides/source/active_record_querying.textile @@ -356,20 +356,6 @@ Client.where("created_at >= :start_date AND created_at <= :end_date", This makes for clearer readability if you have a large number of variable conditions. -h5(#array-range_conditions). Range Conditions - -If you're looking for a range inside of a table (for example, users created in a certain timeframe) you can use the conditions option coupled with the +IN+ SQL statement for this. If you had two dates coming in from a controller you could do something like this to look for a range: - -<ruby> -Client.where(:created_at => (params[:start_date].to_date)..(params[:end_date].to_date)) -</ruby> - -This query will generate something similar to the following SQL: - -<sql> - SELECT "clients".* FROM "clients" WHERE ("clients"."created_at" BETWEEN '2010-09-29' AND '2010-11-30') -</sql> - h4. Hash Conditions Active Record also allows you to pass in hash conditions which can increase the readability of your conditions syntax. With hash conditions, you pass in a hash with keys of the fields you want conditionalised and the values of how you want to conditionalise them: @@ -392,8 +378,6 @@ NOTE: The values cannot be symbols. For example, you cannot do +Client.where(:st h5(#hash-range_conditions). Range Conditions -The good thing about this is that we can pass in a range for our fields without it generating a large query as shown in the preamble of this section. - <ruby> Client.where(:created_at => (Time.now.midnight - 1.day)..Time.now.midnight) </ruby> |