On rails using will_paginate and partials

I have a collection of people who are paginated with will_paginate

@people = Person.paginate :page => params[:page],
                :limit => 10,
                    :conditions =>   ['company_id = ? ' , @company.id ] 

People are displayed on the company / view page and are displayed partially. Note that the partial is in the views of people

<%= render :partial => "people/person" , :locals => { :people => @people }%>

in partial ...

<% for person in @people %>

     ...

<%end%>

<%= will_paginate @people %>

Now the part is working, it displays all the people and shows links to the pages below. However, in fact, it does not paginate the collection, but displays everything on the first page.

I am clearly missing something quite elementary.

Thanks in advance.

+3
source share
2 answers

Do you miss per_page?

+2
source

Per_page .

:page => params[:page] :page => params[:page] || 1, will_paginate .

+1

Source: https://habr.com/ru/post/1702191/


All Articles