Chris Tosswill
Chris Tosswill

Reputation: 187

in rails using will_paginate and partials

I have a collection of people that is paginated with will_paginate

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

The people are shown on the company/view page and rendered with a partial. Note that the partial is in the views of 'people'

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

in the partial ...

<% for person in @people %>

     ...

<%end%>

<%= will_paginate @people %>

Now the partial does work, it renders all of the people and shows the paginate links on the bottom. However it doesn't not actually paginate the collection and instead it shows everything on the first page.

I am clearly missing something rather basic.

Thanks in advance.

Upvotes: 3

Views: 2423

Answers (2)

Bandito
Bandito

Reputation:

Per_page should be the problem.

Also make :page => params[:page] look like :page => params[:page] || 1 so that will_paginate will stop complaining on blank page parameters.

Upvotes: 1

geowa4
geowa4

Reputation: 41853

Are you missing per_page?

Upvotes: 2

Related Questions