MultiModel elasticsearch的分页

时间:2015-11-05 21:37:45

标签: ruby-on-rails elasticsearch pagination will-paginate

我在我的控制器中执行多模型elasticsearch并且没有设法将结果与will_paginate gem一起分页。

在我的控制器中我有:

def index
   @people = Elasticsearch::Model.search('*', [Authors, Editors])
end

然后在我看来,我有:

<table>
  <thead>
    <tr>
      <th>Name</th>
    </tr>
  </thead>
  <tbody>
    <% @people.each do |person| %>
      <tr>
        <td><%= person.name %></td>
      </tr>
    <% end %>
  </tbody>
</table>
<%= will_paginate @people, renderer: BootstrapPagination::Rails %>

持续获得的主要错误是undefined method 'total_pages' for #<Array:0x007fd8b0e32660>

1 个答案:

答案 0 :(得分:1)

它为我工作:

@people = Elasticsearch::Model.search('', [Model1, Model2]).page(page).per(per_page).records

视图

@people.results