2013-09-02 4 views
0

새해를 보냈을 때이 후반기를 보낸 후. 내 인덱스 컨트롤러 trying to set a default 종류의 더듬다를 사용하는 동안이 오류를 얻기과 잘 모르겠어요 것은Ransack 사용자 정의 기본 정렬

undefined method `split' for #<Post:0x007fabedac69a8> 

여기에 활성 기록 명성을 사용하여 내 컨트롤러

class PostsController < ApplicationController 
    def index 
    @search = Post.search(params[:q]) 
    @search.sorts = Post.find_with_reputation(:votes,:all, order: "votes desc") if @search.sorts.empty? 
    @posts = @search.results 
    end 
end 

이고 기본 부하가 가장 높은 정렬 기준으로 사용할 이유 보시다시피 어쩌면 정렬 된 표를 가진 페이지로드를 달성하고 렁 차지 검색을 허용하는 더 좋은 방법이 있습니까? 철저히 혼란스러워.

+0

'@ search.sorts'는 무엇인가? –

+0

'find_with_reputation' 어디서 쓰여졌습니까? –

답변

2

대신 @ search.sort 대신 다른 변수에 할당하십시오. 또한 대신 결과는 결과 사용

class PostsController < ApplicationController 
    def index 
    @search = Post.search(params[:q]) 
    @search_r = Post.find_with_reputation(:votes,:all, order: "votes desc") if @search.sorts.empty? 
    @posts = @search_r.result 
    end 
end 
+0

엄지 손가락 .... ... ... –