2015-11-05 20 views
0

我在我的控制器中執行多模型彈性搜索,並沒有設法得到結果與will_paginate寶石分頁。分頁爲MultiModel elasticsearch

在我的控制,我有:

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

這對我的工作:

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

和視圖

@people.results 
+0

使用雷... will_paginate是過時 –