0

다음 모델이 있는데 "with_query"에 여러 매개 변수를 전달하고이를 달성하는 방법을 모르겠습니다. 현재 "쿼리"매개 변수 만 필요하다는 것을 알 수 있습니다. 어떻게 country와 job_type으로 필터링 할 수 있습니까? 어떤 도움이라도 정말 감사 할 것입니다.레일스가 검색 쿼리에서 여러 개의 Params를 처리합니다.

검색 모델

def self.search(query, country, job_type, page = 1) 

     results = [] 

     Refinery.searchable_models.each do |model| 
     results << model.limit(RESULTS_LIMIT).with_query(query) 
     end if query.present? 

     results.flatten[0..(RESULTS_LIMIT - 1)] 

    end 

컨트롤러 I가 검색 모델의 결과를 기반으로 라인을 변경하려고 할 것이다

def show 
    @results = Refinery::SearchEngine.search(params[:query], params[:country], params[:job_type], params[:page]) 
    present(@page = Refinery::Page.find_by_link_url("/search")) 
    end 

답변

1

: 멋진 에드워드의

results << model.limit(RESULTS_LIMIT).with_query(query).where(country: country, job_type: job_type) 
+0

너의 연구에 감사드립니다. 응답. 그게 내 문제를 분류 했어. – JAML

관련 문제