我刚刚开始在我的 Rails 4 应用程序中实现轮胎 gem 和 ElasticSearch。在轮胎宝石主页上,它指出:
Note that Tire search results are fully compatible with WillPaginate and Kaminari, so you can pass all the usual parameters to the search method in the controller:
    @articles = Article.search params[:q], :page => (params[:page] || 1)
我有几乎完全相同的设置:
  @projects = Project.search params[:query], :load => true, :page => (params[:page] || 1)
当我尝试搜索时,我得到:
undefined method `total_pages' for #<ActiveRecord::Relation []>
项目.rb:
  include Tire::Model::Search
  include Tire::Model::Callbacks
  settings :analysis => {
      :filter  => {
          :ngram_filter => {
              :type => "nGram",
              :min_gram => 2,
              :max_gram => 12
          }
      },
      :analyzer => {
          :index_ngram_analyzer => {
              :type  => "custom",
              :tokenizer  => "standard",
              :filter  => ["lowercase", "ngram_filter"]
          },
          :search_ngram_analyzer => {
              :type  => "custom",
              :tokenizer  => "standard",
              :filter  => ["standard", "lowercase", "ngram_filter"]
          }
      }
  } do
    mapping do
      indexes :id, :type => 'integer'
      indexes :title
      indexes :description
    end
  end
如何使用 WillPaginate 正确对搜索结果进行分页?任何帮助表示赞赏。