in my Rails project I am trying to use the following query in a search form_tag
Student.joins(:courses).where(@params.joins(','), @values)
where params and values are dynamically constructed arrays since there are some optional parameters in the search. An example from my code:
if params[:date_begin] != ''
@params.push " courses.date_begin >= ? "
@values.push params[:date_begin]
end
The problem is the @values array is being considered as one argument and raises this error:
wrong number of bind variables (1 for 2)
How do I tell it to consider the array elements separately?