diff options
author | Pratik Naik <pratiknaik@gmail.com> | 2010-08-30 23:12:58 +0100 |
---|---|---|
committer | Pratik Naik <pratiknaik@gmail.com> | 2010-08-30 23:45:03 +0100 |
commit | 1e554a11758fcbe6ffcd929d98c02cdac9a37bbc (patch) | |
tree | 6d7573db3227ef7061006e5fba70433dd8e9c382 | |
parent | 3805d01c9b0ee6681d3e36233a82731200b87d34 (diff) | |
download | rails-1e554a11758fcbe6ffcd929d98c02cdac9a37bbc.tar.gz rails-1e554a11758fcbe6ffcd929d98c02cdac9a37bbc.tar.bz2 rails-1e554a11758fcbe6ffcd929d98c02cdac9a37bbc.zip |
Array conditions dont need []
-rw-r--r-- | railties/guides/source/active_record_querying.textile | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/railties/guides/source/active_record_querying.textile b/railties/guides/source/active_record_querying.textile index 178a5c50bf..95d992bd3e 100644 --- a/railties/guides/source/active_record_querying.textile +++ b/railties/guides/source/active_record_querying.textile @@ -234,7 +234,7 @@ h4. Array Conditions Now what if that number could vary, say as an argument from somewhere, or perhaps from the user's level status somewhere? The find then becomes something like: <ruby> -Client.where(["orders_count = ?", params[:orders]]) +Client.where("orders_count = ?", params[:orders]) </ruby> Active Record will go through the first element in the conditions value and any additional elements will replace the question marks +(?)+ in the first element. @@ -242,7 +242,7 @@ Active Record will go through the first element in the conditions value and any Or if you want to specify two conditions, you can do it like: <ruby> -Client.where(["orders_count = ? AND locked = ?", params[:orders], false]) +Client.where("orders_count = ? AND locked = ?", params[:orders], false) </ruby> In this example, the first question mark will be replaced with the value in +params[:orders]+ and the second will be replaced with the SQL representation of +false+, which depends on the adapter. @@ -250,7 +250,7 @@ In this example, the first question mark will be replaced with the value in +par The reason for doing code like: <ruby> -Client.where(["orders_count = ?", params[:orders]]) +Client.where("orders_count = ?", params[:orders]) </ruby> instead of: |