From 1e554a11758fcbe6ffcd929d98c02cdac9a37bbc Mon Sep 17 00:00:00 2001 From: Pratik Naik Date: Mon, 30 Aug 2010 23:12:58 +0100 Subject: Array conditions dont need [] --- railties/guides/source/active_record_querying.textile | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'railties/guides') 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: -Client.where(["orders_count = ?", params[:orders]]) +Client.where("orders_count = ?", params[:orders]) 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: -Client.where(["orders_count = ? AND locked = ?", params[:orders], false]) +Client.where("orders_count = ? AND locked = ?", params[:orders], false) 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: -Client.where(["orders_count = ?", params[:orders]]) +Client.where("orders_count = ?", params[:orders]) instead of: -- cgit v1.2.3