我有以下的控制方法searchlogic - 陣列錯誤
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?
有沒有解決上述問題的方法?
非常感謝您的寶貴幫助。
非常感謝您的建議,但它不工作現在:(我越來越:未定義的方法'秩序」爲#<字符串: 0xb6157cbc> – Kim
請問我爲什麼要做search2 + search1 –
原因是因爲我需要添加2個示波器的結果並執行搜索 – Kim