Multiple form fields for condition statement

I have a search form with multiple imputs and I want to build the sql
command using the find method with multiple conditions. below is the
code I’m using. When I just enter in 1 field (any of the ****value
variables) everything works out fine. but if I enter 2 or more, i get
the following message. and I have used puts statements to see what the
actual variable is that I’m passing to the :condition statement, and it
is building the array correctly, as far as I can tell. but it still
doesn’t like me. ~
~

Any help is good help.

thanks.

ActiveRecord::PreparedStatementInvalid in StoreController#search

wrong number of bind variables (1 for 2) in: first_name like ? and
last_name like ?

def self.find_lead(vin_type, vin_text, fname_type, fname_text, lname_type, lname_text, li_type, li_text, email_type, email_text) if vin_type == "equals" op1 = "=" else op1 = "like" end if fname_type == "equals" op2 = "=" else op2 = "like" end if lname_type == "equals" op3 = "=" else op3 = "like" end if li_type == "equals" op4 = "=" else op4 = "like" end if email_type == "equals" op5 = "=" else op5 = "like" end front_value_modifier = {"equals" => "", "contains"=> "%", "begins_with"=> "", "ends_with"=> "%"} back_value_modifier = {"equals" => "", "contains"=> "%", "begins_with"=> "%", "ends_with"=> ""}
 v=""
 x = []
 if fname_text == ""
   v=v
 else
   if v == ""
     v="first_name #{op2} ? "
   end
   x <<

front_value_modifier[fname_type]+fname_text+back_value_modifier[fname_type]
end

 if lname_text == ""
   v=v
 else
   if v == ""
     v="last_name #{op3} ? "
   else
     v=v+"and last_name #{op3} ? "
   end
   x <<

front_value_modifier[lname_type]+lname_text+back_value_modifier[lname_type]
end

 if email_text == ""
   v=v
 else
   if v == ""
     v="email #{op5} ? "
   else
     v=v+"and email #{op5} ? "
   end
   x <<

front_value_modifier[email_type]+email_text+back_value_modifier[email_type]
end

 if li_text == ""
   v=v
 else
   if v == ""
     v="leadid #{op4} ? "
   else
     v=v+"or leadid #{op4} ? "
   end
   x <<

front_value_modifier[li_type]+li_text+back_value_modifier[li_type]
end

 if vin_text == ""
   v=v
 else
   if v == ""
     v="vin_number #{op1} ? "
   else
     v=v+"or vin_number #{op1} ? "
   end
   x <<

front_value_modifier[vin_type]+vin_text+back_value_modifier[vin_type]
end
w = [v,w]
if v==""
find(:all,:limit => 0)
else
find(:all,
:conditions => w,
:order => “vin_number”,
:limit => 10
)
end
end

sorry, the at the very bottom of the code, it should be w = [v,x] not w
= [v,w]

front_value_modifier[vin_type]+vin_text+back_value_modifier[vin_type]
end
w = [v,w]
if v==""
find(:all,:limit => 0)
else
find(:all,
:conditions => w,
:order => “vin_number”,
:limit => 10
)
end
end