我有以下控制器方法
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
如果我将代码更改为'@search = @search1'
,它可以正常运行并返回结果但是当我执行'@search = @search2 + @search1'
时,我会收到以下错误消息:
TypeError in ApparatusesController#app_used_by_Lab
can't convert Searchlogic::Search into Array
是否无法在数组上使用searchlogic?
上述问题有解决方法吗?
非常感谢您的宝贵帮助。
答案 0 :(得分:0)
请试试这个:
@search = @search2.to_s + @search1.to_s
答案 1 :(得分:0)
试试这个:
@search = @search2.concat(@search1)