I’am trying to create a search sytem with two arguments
When one argument is choosen it needs find all the objects with that
argument
and when two choosen it needs to find all objects with both arguments.
@gardens = Garden.find(:all, :conditions => [“provincie = ? and
heading_id = ? and destroyed = 0”, @params[:search], @params[:heading] ]
This variant of :conditions creates a SQL fragment for a where clause
that replaces the ?'s in order with the values provided after the
first comma (and has the added benefit of preventing SQL injection).
I want a system when i choose only a province i get all gardens in that
specific province
And when i set the heading i get all gardens with that specific heading
And when i set them both i get all gardens in that province and that
heading
In this way only when i set both i get the right results even like the
system i had in the post above.
This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.