views:

448

answers:

2

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.

+2  A: 

Are you missing per_page?

geowa4
A: 

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.

Bandito