2011-10-28 13 views
7

最近、私のインデックスエンジンをsphinxからsolrに移植することに決めました。 thinking_sphinxとkaminariを使用したので、私は黒点/https://github.com/sunspot/sunspot/pull/67でジェネリックページネーションを使ってwill_paginateに移動しないようにすることにしました。次のようにSunspotとkaminariのページ分割

私の検索が処理されます

@search = Address.search do 
    fulltext params[:search] 
    with(:updated_at).greater_than(1.week.ago) 
    order_by :updated_at, :desc 
    paginate :page => params[:page], :per_page => 7 
end 

私の見解は、私がthinking_sphinxを使用していたとき、私が持っていたものから変更されていません:

<%= render :partial => 'address' %> 
<%= paginate @addresses %> 

私の問題は、その変更後の私は絶えずあります検索を実行しようとすると次のエラーが表示されます。

undefined method `current_page' for []:Array 

私は私の知識に雷を使用するように私を有効にする必要がありますされ、黒点の最新バージョンを使用しています:

Using sunspot (1.3.0.rc3) from git://github.com/sunspot/sunspot.git (at master) 
Using sunspot_rails (1.3.0.rc3) from git://github.com/sunspot/sunspot.git (at master) 

これは私の古いthinking_sphinxセットアップを完全に働いたので、私は間違って何をやっていますか?

+0

まあ、私はそれを動作させるためにしようとしての疲れとwill_paginateに切り替え、素晴らしい作品を持っているのビューで動作します今。 – maecro

+2

カミナリと太陽黒点をうまく一緒にする太陽黒点カミナリの宝石があります。[https://github.com/richardiux/sunspot_with_kaminari](https://github.com/richardiux/sunspot_with_kaminari)は私たちのためにはうまくいきます。 –

+0

私はその宝石を見ていましたが、そこにはたくさんの活動がないように見えるので、その時は見落とされました。おそらく私はそれを幾分厳しく判断した、私はそれをもう一度見てみましょう。推薦のための喝采。 – maecro

答えて

13

これは私が使用しているかであり、それは素晴らしい

@search = Sunspot.search(Listing) do 
     if params[:category].present? 
     with :category_id, params[:category] 
     end 
     if params[:subcategory].present? 
     with :subcategory_id, params[:subcategory] 
     end 
     if params[:q].present? 
     keywords params[:q] do 
      fields :title, :description 
     end 
     end 
     paginate :page => params[:page], :per_page => SEARCH_RESULT_PER_PAGE 
    end 

そして、私はこの

<%= paginate @search.hits %> 
+0

あなたは私に多くの時間を救った!ありがとう! – 23tux