用于#<thinkingsphinx :: search:0x000000046a9650> </thinkingsphinx :: search:0x000000046a9650>的未定义方法`paginate'

时间:2013-09-27 14:23:07

标签: ruby-on-rails ruby-on-rails-3.2 thinking-sphinx will-paginate ruby-1.9.3

我正在使用rails 3.2.13,sphinx服务器工作正常,在我安装了will_paginate 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 'will_paginate','>= 3.0.pre'

结果没有显示,我做了什么错误?

1 个答案:

答案 0 :(得分:1)

您应该使用pagination of Thinking Sphinx

@properties = Property.search("*#{query}*", :page=>params[:page], :per_page=>5)