1

will_paginate をインストールした後、正常に動作する sphinx サーバーである Rails 3.2.13 を使用しています。gem のページネーションが機能しません。

エラーは次のとおりです。

 NoMethodError in DashboardsController#search

undefined method `paginate' for #<ThinkingSphinx::Search:0x000000046a9650>
app/controllers/dashboards_controller.rb:12:in `search'

これは私の Dashboard Cotroller のコードです

class DashboardsController < ApplicationController    
  def search
    query=[]
    query << "#{params[:property_listing]}" if(params[:property_listing]).present?
    query << "#{params[:property_type]}" if(params[:property_type]).present?
    query << "#{params[:city]}" if(params[:city]).present?
    query << "#{params[:sale_price]}" if(params[:sale_price]).present?
    @properties = Property.search("*#{query}*").paginate(:page=>params[:page], :per_page=>5)
    @json = @properties.to_gmaps4rails
    respond_to do |format|
      format.html
    end
  end
end

search.html.erb

<% @properties.each do |property| %>
 //some codes which is working fine before using pagination
<% end %>
<%= will_paginate(@properties) %>

gemをインストールしました

gem 'will_paginate','>= 3.0.pre'

結果が表示されません。

4

1 に答える 1

1

Thinking Sphinx のページネーションを使用する必要があります。

@properties = Property.search("*#{query}*", :page=>params[:page], :per_page=>5)    
于 2013-09-27T14:44:12.727 に答える