searchlogic - array error

99 views Asked by At

I have the following controller method

def app_used_by_Lab
    per_id = params[:id]

    @search1 = Apparatus.used_by_specific_lab(per_id).search(params[:search]) # both 'used_by_specific_lab' & 'lab_created' are named_scopes which return results from the same table
    @search2 = Apparatus.lab_created(per_id).search(params[:search])
    @search = @search2 + @search1
    @search.order ||= :descend_by_RPR_DATE_CREATED
    @apparatuses = @search.paginate(:page => params[:page], :per_page => 10)
end

If I change the code to '@search = @search1', it works fine and return me the results but when I do '@search = @search2 + @search1', I get the error message below:

TypeError in ApparatusesController#app_used_by_Lab

can't convert Searchlogic::Search into Array

Is it not possible to use searchlogic on arrays?

Is there any solution to the above problem?

Thanks a lot for your precious help.

2

There are 2 answers

5
suresh gopal On

Please Try this:

@search = @search2.to_s + @search1.to_s
1
Dipak Panchal On

try this:

@search =  @search2.concat(@search1)